Bug 25067 - Move PO file manipulation code into gulp tasks
Summary: Move PO file manipulation code into gulp tasks
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Julian Maurice
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 26547 26971 28154
  Show dependency treegraph
 
Reported: 2020-04-06 06:44 UTC by Julian Maurice
Modified: 2021-12-13 21:12 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00
Circulation function:


Attachments
Bug 25067: Move PO file manipulation code into gulp tasks (96.58 KB, patch)
2020-04-06 06:45 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add missing globs in gulpfile for po:extract (1.29 KB, patch)
2020-04-21 15:12 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Move PO file manipulation code into gulp tasks (96.69 KB, patch)
2020-04-21 18:51 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 25067: Add missing globs in gulpfile for po:extract (1.36 KB, patch)
2020-04-21 18:51 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 25067: Add translate create|update commands that call gulp (1.14 KB, patch)
2020-04-22 07:36 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add license notice to xgettext* scripts (4.26 KB, patch)
2020-04-23 10:27 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Hide deprecation notice unless --verbose flag is given (1.07 KB, patch)
2020-04-23 10:27 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Move PO file manipulation code into gulp tasks (96.69 KB, patch)
2020-04-23 10:41 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 25067: Add missing globs in gulpfile for po:extract (1.36 KB, patch)
2020-04-23 10:41 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 25067: Add translate create|update commands that call gulp (1.20 KB, patch)
2020-04-23 10:41 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 25067: Add license notice to xgettext* scripts (4.33 KB, patch)
2020-04-23 10:41 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 25067: Hide deprecation notice unless --verbose flag is given (1.13 KB, patch)
2020-04-23 10:41 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 25067: Move PO file manipulation code into gulp tasks (96.50 KB, patch)
2020-07-03 13:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add missing globs in gulpfile for po:extract (1.36 KB, patch)
2020-07-03 13:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add translate create|update commands that call gulp (1.20 KB, patch)
2020-07-03 13:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add license notice to xgettext* scripts (4.33 KB, patch)
2020-07-03 13:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Hide deprecation notice unless --verbose flag is given (1.13 KB, patch)
2020-07-03 13:16 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Do not set msgctxt in pref PO files (2.79 KB, patch)
2020-07-12 17:05 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Move PO file manipulation code into gulp tasks (95.84 KB, patch)
2020-08-28 10:23 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add missing globs in gulpfile for po:extract (1.32 KB, patch)
2020-08-28 10:23 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add translate create|update commands that call gulp (1.20 KB, patch)
2020-08-28 10:23 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add license notice to xgettext* scripts (4.33 KB, patch)
2020-08-28 10:23 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Hide deprecation notice unless --verbose flag is given (1.13 KB, patch)
2020-08-28 10:23 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Do not set msgctxt in pref PO files (2.79 KB, patch)
2020-08-28 10:23 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Update tests for xgettext-pref (1.78 KB, patch)
2020-08-29 16:20 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Fix globs for staff and opac string extraction (1.56 KB, patch)
2020-08-29 16:20 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Fix translation of system preferences files (4.40 KB, patch)
2020-08-29 16:20 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Move PO file manipulation code into gulp tasks (96.31 KB, patch)
2020-09-13 11:40 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add missing globs in gulpfile for po:extract (1.32 KB, patch)
2020-09-13 11:40 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add translate create|update commands that call gulp (1.20 KB, patch)
2020-09-13 11:41 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Add license notice to xgettext* scripts (4.33 KB, patch)
2020-09-13 11:41 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Hide deprecation notice unless --verbose flag is given (1.13 KB, patch)
2020-09-13 11:41 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Do not set msgctxt in pref PO files (2.79 KB, patch)
2020-09-13 11:41 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Update tests for xgettext-pref (1.78 KB, patch)
2020-09-13 11:41 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Fix globs for staff and opac string extraction (1.56 KB, patch)
2020-09-13 11:41 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Fix translation of system preferences files (4.40 KB, patch)
2020-09-13 11:41 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Move PO file manipulation code into gulp tasks (99.50 KB, patch)
2020-09-26 08:18 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 25067: Move PO file manipulation code into gulp tasks (99.67 KB, patch)
2020-10-14 21:22 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 25067: (QA follow-up) Add +x on test files (804 bytes, patch)
2020-10-14 21:22 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 25067: Move the tests to db_dependent (2.33 KB, patch)
2020-11-06 14:31 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 25067: Adjust paths in tests (2.19 KB, patch)
2020-11-06 16:00 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 25067: Fix perlcritic errors (1.93 KB, patch)
2020-11-06 16:07 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Julian Maurice 2020-04-06 06:44:42 UTC

    
Comment 1 Julian Maurice 2020-04-06 06:45:31 UTC Comment hidden (obsolete)
Comment 2 Katrin Fischer 2020-04-06 06:56:00 UTC
I wonder about the pref file - the # comment kept all strings for one pref together and we have translated "Do" and "Don't" quite differently for some of them, according to context as it works not really well to put the Verb in front of the sentence in German like that. So it appearing more than once was a feature for us. Can we keep that?
Comment 3 Julian Maurice 2020-04-06 07:05:13 UTC
(In reply to Katrin Fischer from comment #2)
> I wonder about the pref file - the # comment kept all strings for one pref
> together and we have translated "Do" and "Don't" quite differently for some
> of them, according to context as it works not really well to put the Verb in
> front of the sentence in German like that. So it appearing more than once
> was a feature for us. Can we keep that?

That feature is kept. msgids will be identical ("Do") but msgctxt won't ("Section > Subsection > Syspref"), allowing translators to give different translations depending on the context.
Comment 4 Katrin Fischer 2020-04-06 20:11:13 UTC
Thx Julian.
Comment 5 Bernardo Gonzalez Kriegel 2020-04-21 14:36:54 UTC
Hi Julian, nice work.

I did a comparison of the msgids on each PO file before and after patch.
pref file needed some touching, I removed the text that now is excluded using
's/\".*#\s/\"/;s/\".*\.pref\s/\"/;'

Comparing only msgid, then doing a diff and counting different lines before (old) and after (new) I got (filename old new)

xx-YY-installer-MARC21.po 0 0
xx-YY-installer.po 0 0
xx-YY-marc-MARC21.po 0 2  *
xx-YY-marc-NORMARC.po 0 0
xx-YY-marc-UNIMARC.po 0 0
xx-YY-messages-js.po 0 0
xx-YY-messages.po 0 2 *
xx-YY-opac-bootstrap.po 4 0 +
xx-YY-pref.po 19 17 #
xx-YY-staff-prog.po 49 0 +

There are a few differences :)
Lines with (*) are new strings, great
Lines with (#), preference file, most differences expected here, most can be ignored
Lines with (+), missing strings after patch

On opac
< msgid "000 "
< msgid "LCCN:"
< msgid "MARC Card View"
< msgid "MARC View"

examples on staff
< msgid "Gone no address flag"
< msgid "Illustrations"
< msgid "Item number"
< msgid "Item number (internal)"
< msgid "Koha itemtype"
< msgid "Koha normalized classification for sorting"
< msgid "Lost card flag"
< msgid "MARC Card View"
< msgid "MARC View"
Comment 6 Julian Maurice 2020-04-21 14:56:29 UTC
Thanks Bernardo for this detailed analysis. It looks like I forgot some files in the gulp globs. In particular columns.def and the XSL files that are not related to a specific marc flavour.
I will try to fix that ASAP.
Comment 7 Julian Maurice 2020-04-21 15:12:31 UTC Comment hidden (obsolete)
Comment 8 Julian Maurice 2020-04-21 15:14:59 UTC
With the last patch I get the same count of msgid than on master for opac-bootstrap and staff-prog
Comment 9 Bernardo Gonzalez Kriegel 2020-04-21 16:30:17 UTC
(In reply to Julian Maurice from comment #8)
> With the last patch I get the same count of msgid than on master for
> opac-bootstrap and staff-prog

Yes, they have the same content :)

Last question: some may be used to the old syntax, doing ./translate create|update on misc/translator/, they need to use it anyway to do the install

What do you think of executing 'gulp' from translate script?
and perhaps using "--silent" to suppress messages unless verbose mode is requested?
Comment 10 Bernardo Gonzalez Kriegel 2020-04-21 18:51:20 UTC Comment hidden (obsolete)
Comment 11 Bernardo Gonzalez Kriegel 2020-04-21 18:51:25 UTC Comment hidden (obsolete)
Comment 12 Julian Maurice 2020-04-22 06:01:26 UTC
(In reply to Bernardo Gonzalez Kriegel from comment #9)
> (In reply to Julian Maurice from comment #8)
> > With the last patch I get the same count of msgid than on master for
> > opac-bootstrap and staff-prog
> 
> Yes, they have the same content :)
> 
> Last question: some may be used to the old syntax, doing ./translate
> create|update on misc/translator/, they need to use it anyway to do the
> install
> 
> What do you think of executing 'gulp' from translate script?
> and perhaps using "--silent" to suppress messages unless verbose mode is
> requested?

I think it is not needed, but it can't hurt to have it. Maybe QA has an opinion on that ?
Comment 13 Katrin Fischer 2020-04-22 06:36:53 UTC
Hi Julian and Bernardo, happy to see the thorough testing of this change. 

If we could make koha-translate and the translate script behave the same with this change than before, I'd be in favor of it.
Comment 14 Julian Maurice 2020-04-22 07:11:51 UTC
It seems that koha-translate only uses the 'install' mode of misc/translator/translate, so its behavior should not change.
Comment 15 Julian Maurice 2020-04-22 07:36:08 UTC Comment hidden (obsolete)
Comment 16 Bernardo Gonzalez Kriegel 2020-04-22 10:47:49 UTC
(In reply to Julian Maurice from comment #15)
> Created attachment 103440 [details] [review] [review]
> Bug 25067: Add translate create|update commands that call gulp

Sorry to bother you with this, but can we left the deprecation notice for verbose mode? 
I would like the 'same' behavior as before
(It's my liking of course, and you can ignore it. I'll sign anyway)

Finally, files gulpfile.js, xgettext-installer, xgettext-pref and xgettext-tt2 need a copyright notice.
Comment 17 Julian Maurice 2020-04-22 11:06:04 UTC
(In reply to Bernardo Gonzalez Kriegel from comment #16)
> Sorry to bother you with this, but can we left the deprecation notice for
> verbose mode? 
> I would like the 'same' behavior as before
> (It's my liking of course, and you can ignore it. I'll sign anyway)

In my opinion, people should be warned even if they don't want to, and they can use gulp directly if they don't want to see this warning, right ? :)
But in the end, you are probably the only one directly concerned by this change, so if you think it's better this way, I'll make those changes ASAP
Comment 18 Julian Maurice 2020-04-23 10:27:19 UTC Comment hidden (obsolete)
Comment 19 Julian Maurice 2020-04-23 10:27:22 UTC Comment hidden (obsolete)
Comment 20 Bernardo Gonzalez Kriegel 2020-04-23 10:41:45 UTC Comment hidden (obsolete)
Comment 21 Bernardo Gonzalez Kriegel 2020-04-23 10:41:48 UTC Comment hidden (obsolete)
Comment 22 Bernardo Gonzalez Kriegel 2020-04-23 10:41:52 UTC Comment hidden (obsolete)
Comment 23 Bernardo Gonzalez Kriegel 2020-04-23 10:41:56 UTC Comment hidden (obsolete)
Comment 24 Bernardo Gonzalez Kriegel 2020-04-23 10:41:59 UTC Comment hidden (obsolete)
Comment 25 Bernardo Gonzalez Kriegel 2020-04-23 10:42:45 UTC
All tested and signed!
Comment 26 Julian Maurice 2020-07-03 13:16:12 UTC Comment hidden (obsolete)
Comment 27 Julian Maurice 2020-07-03 13:16:16 UTC Comment hidden (obsolete)
Comment 28 Julian Maurice 2020-07-03 13:16:19 UTC Comment hidden (obsolete)
Comment 29 Julian Maurice 2020-07-03 13:16:24 UTC Comment hidden (obsolete)
Comment 30 Julian Maurice 2020-07-03 13:16:28 UTC Comment hidden (obsolete)
Comment 31 Julian Maurice 2020-07-03 13:18:26 UTC
All patches rebased on master
Comment 32 Alex Arnaud 2020-07-10 14:23:21 UTC
I agree with the fact that the translate script should behave the same way than before. But i think it's not possible.

I think of people that will upgrade with the gulp feature and surprisingly note that the script no longer works for create or update if they didn't install the gulp-cli / yarn command.

My feeling is that we should have the command ./translate create|update telling the user: "Creating or updating po process has changed, please use it the way <here>" 

Bernardo, Katrin any thoughts ?
Comment 33 Alex Arnaud 2020-07-10 14:27:10 UTC
Also, i have concerns about the .pot generated. They are no longer cleaned now.
Do we need these .pot files actually ?
Comment 34 Katrin Fischer 2020-07-12 12:00:49 UTC
I don't know about the .pot files, but was looking at the test plan again (thx for the write-up!):

- Can 'gulp po:update' be run for a selected language? It takes a long while to do this for all languages, so you might want to do it only for the ones you need/test with.

- In the test plan only installing a language is used with the old syntax, creating and updating are different. I think mixing would not be good. Why is it not possible to move all to the old syntax? and should we them move installing as well with the deprecation note you suggest?

You write:
>- there is no need for $KOHA_CONF to be defined
>  LangInstaller.pm relied on $KOHA_CONF to get the different paths
>  needed. I'm not sure why, since string extraction and PO update should
>  work on source files, not installed files

But aren't the paths to the templates we need to parse different depending on installation type? And also the po files will be stored in a different place?

We need to keep the option for everyone to update/install their own adapted po files. I know a lot of people make local changes. Even we do to a certain extend to have our own XSLT files translated.

Still a bit worried about this one:

>  Now context is put into msgctxt, and the reference is set, which is
>  cleaner

>    #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref
>    msgctxt "Accounting > Policy > FinePaymentAutoPopup"
>    msgid "automatically display a print dialog for a payment receipt "
>    "when making a payment.."

I think in translation practice using Pootle this could be quite hard on tranlators. :(

Right now you can search in the prefs file for a system preference and it will turn up all strings related to it. They also appear in alphabetic order, so when you start translating, you have the 'context' because the strings appear together with the prefixed note. This was intentional and a 'feature'. 

It doesn't seem that we can search by 'context' in Pootle, so seeing all strings for a pref together will no longer be possible.

To explain: Translating prefs is quite hard because you have to make sure things work grammatically with sentence parts torn apart. This depends on language I am sure, but for German it's not an easy task and we can't translate "Do" and "Don't" just like that. Often we need to move parts of the rest of the sentence into the options for things to make more sense.

Also:

>  The downside is that some messages will have to be re-translated,
>  especially short messages like 'Do', for which msgmerge has a hard
>  time finding the corresponding new msgid.

This is quite a burden for translators, escpecially since you have to look up every single one of them to see what the rest of the sentence looks like. Can't we figure them out? We do have the pref and the current translation.
Comment 35 Katrin Fischer 2020-07-12 12:07:51 UTC
> - In the test plan only installing a language is used with the old syntax,
> creating and updating are different. I think mixing would not be good. Why
> is it not possible to move all to the old syntax? and should we them move
> installing as well with the deprecation note you suggest?

Realizing that last bit made no sense:

And should we not move installing to the new syntax as well with a deprecation note like you suggest? 

Overall I think we need to keep things as easy as possible since not only experienced Koha users will be using these commands (update, install, create).
Comment 36 Julian Maurice 2020-07-12 16:29:10 UTC
(In reply to Katrin Fischer from comment #34)
> I don't know about the .pot files, but was looking at the test plan again
> (thx for the write-up!):
> 
> - Can 'gulp po:update' be run for a selected language? It takes a long while
> to do this for all languages, so you might want to do it only for the ones
> you need/test with.
Yep, just use --lang option:

  gulp po:update --lang de-DE

> You write:
> >- there is no need for $KOHA_CONF to be defined
> >  LangInstaller.pm relied on $KOHA_CONF to get the different paths
> >  needed. I'm not sure why, since string extraction and PO update should
> >  work on source files, not installed files
> 
> But aren't the paths to the templates we need to parse different depending
> on installation type? And also the po files will be stored in a different
> place?
I believe create and update operations should work exclusively on source files. I don't see why we would want to work on the copy installed under /usr/share/koha for instance.
Note that 'install' operation still work the same, translated templates are installed in the right place.

> 
> We need to keep the option for everyone to update/install their own adapted
> po files. I know a lot of people make local changes. Even we do to a certain
> extend to have our own XSLT files translated.
We do too, but local translations are handled in separate PO files.

Do you alter the original PO files ? How do you handle Koha upgrades ?

> 
> Still a bit worried about this one:
> 
> >  Now context is put into msgctxt, and the reference is set, which is
> >  cleaner
> 
> >    #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/accounting.pref
> >    msgctxt "Accounting > Policy > FinePaymentAutoPopup"
> >    msgid "automatically display a print dialog for a payment receipt "
> >    "when making a payment.."
> 
> I think in translation practice using Pootle this could be quite hard on
> tranlators. :(
> 
> Right now you can search in the prefs file for a system preference and it
> will turn up all strings related to it. They also appear in alphabetic
> order, so when you start translating, you have the 'context' because the
> strings appear together with the prefixed note. This was intentional and a
> 'feature'. 
> 
> It doesn't seem that we can search by 'context' in Pootle, so seeing all
> strings for a pref together will no longer be possible.
It seems that Pootle can search by comment. Would that help if the syspref name and category appear in a comment ?

> 
> To explain: Translating prefs is quite hard because you have to make sure
> things work grammatically with sentence parts torn apart. This depends on
> language I am sure, but for German it's not an easy task and we can't
> translate "Do" and "Don't" just like that. Often we need to move parts of
> the rest of the sentence into the options for things to make more sense.
This will still be possible

> 
> Also:
> 
> >  The downside is that some messages will have to be re-translated,
> >  especially short messages like 'Do', for which msgmerge has a hard
> >  time finding the corresponding new msgid.
> 
> This is quite a burden for translators, escpecially since you have to look
> up every single one of them to see what the rest of the sentence looks like.
> Can't we figure them out? We do have the pref and the current translation.
Probably.
We can also easily revert this change from this patchset and address the issue in a separate bug. This bug brings already too many different things, so if it helps I will gladly remove that. I just thought it would be a nice "clean up" to do at the same time.

(In reply to Katrin Fischer from comment #35)
> > - In the test plan only installing a language is used with the old syntax,
> > creating and updating are different. I think mixing would not be good. Why
> > is it not possible to move all to the old syntax? and should we them move
> > installing as well with the deprecation note you suggest?
> 
> Realizing that last bit made no sense:
> 
> And should we not move installing to the new syntax as well with a
> deprecation note like you suggest? 
> 
> Overall I think we need to keep things as easy as possible since not only
> experienced Koha users will be using these commands (update, install,
> create).
In my opinion, install is really different from create/update so it makes sense for it to be in a different script/called in a different way.
Only install should be called by end users (people who manage Koha instances)
create/update is more for Koha translation maintainer (aka Bernardo)
Comment 37 Julian Maurice 2020-07-12 17:05:40 UTC Comment hidden (obsolete)
Comment 38 Julian Maurice 2020-07-12 17:08:22 UTC
Last patch tested with fr-FR PO files : msgmerge correctly keep all translations (even short ones like "Do"). The only difference is that long lines are now wrapped.
Comment 39 Katrin Fischer 2020-07-12 17:38:27 UTC
Hm, I think I don't understand what you are referring to as source files. Will this work for tarball installations, packaging installations and git based installations alike? I believe we don't always have 2 copies of the files? 
I am worried this could break things for some of those?

Adding the info in a comment could help a bit, I tihnk, but it could get quite a lot, maybe just the names of the prefs?

I think it's a wrong assumption that update and create will only be used by our translation manager or developers. I believe libraries have for example changed terms in po files and similar for the normal GUI. 

But I'd be interested in your workflow for separate po for other use cases. :)
Comment 40 Katrin Fischer 2020-07-12 17:38:45 UTC
(In reply to Julian Maurice from comment #38)
> Last patch tested with fr-FR PO files : msgmerge correctly keep all
> translations (even short ones like "Do"). The only difference is that long
> lines are now wrapped.

That's some good news. :)
Comment 41 Julian Maurice 2020-07-12 18:44:58 UTC
(In reply to Katrin Fischer from comment #39)
> Hm, I think I don't understand what you are referring to as source files.
> Will this work for tarball installations, packaging installations and git
> based installations alike? I believe we don't always have 2 copies of the
> files? 
> I am worried this could break things for some of those?
By source files I mean the files that are committed in the git repo. All files that you have directly after a git clone.
IMO create and update should not be run on "installations", but directly on files inside the git repository, independently of any installation.
'create' and 'update' are essentially developer tools to manage PO files within the git repository.

> I think it's a wrong assumption that update and create will only be used by
> our translation manager or developers. I believe libraries have for example
> changed terms in po files and similar for the normal GUI.
I think that we should not support nor encourage that. Even if it's "only" translations, it's still a fork of Koha. Everyone is free to do that, of course, but then they are on their own to maintain their changes.
If translations are wrong, they should be fixed on translate.koha-community.org

> But I'd be interested in your workflow for separate po for other use cases.
> :)
Basically, for each client-specific development that adds new strings, we create a PO file in misc/translator/po/fr-FR-<category>-<ticket-id>.po containing all the new strings and their translation. When we need to update fr-FR templates we call a script that "concatenates" (msgcat) all fr-FR-<category>-*.po and runs misc/translator/translate install
Comment 42 Julian Maurice 2020-08-28 10:23:03 UTC Comment hidden (obsolete)
Comment 43 Julian Maurice 2020-08-28 10:23:07 UTC Comment hidden (obsolete)
Comment 44 Julian Maurice 2020-08-28 10:23:12 UTC Comment hidden (obsolete)
Comment 45 Julian Maurice 2020-08-28 10:23:16 UTC Comment hidden (obsolete)
Comment 46 Julian Maurice 2020-08-28 10:23:20 UTC Comment hidden (obsolete)
Comment 47 Julian Maurice 2020-08-28 10:23:24 UTC Comment hidden (obsolete)
Comment 48 Julian Maurice 2020-08-28 10:25:39 UTC
Rebased on master (needed because of bug 26228)
Comment 49 Katrin Fischer 2020-08-29 12:35:22 UTC

1. Run `yarn install` and install Locale::XGettext::TT2

It looks like Locale::XGettext::TT2 has no packages for Debian yet, can you confirm?
Ended up installatin from CPAN.
Adding Mason.

2. Run `gulp po:update`

$ gulp po:update
-bash: gulp: command not found
I've tried following this:
https://gulpjs.com/docs/en/getting-started/quick-start/

$ gulp po:update
Finishes this time.

3. Verify the contents of updated PO files

I have verified the contents of the de-DE files. 

Problem: It appears that a strings have jumped from one po file to another, requiring a lot of retranslations. Namely this seems to be the value_builder plugins that are no longer in the MARC flavor files but appear in staff now:

Example string:
twentyfour track

This is now in the UNIMARC file, but with this patch appears in staff.

Question: Reviewing the pref po looks like before, correct?

4. Run `cd misc/translator && ./translate install <lang>`

Testing with de-DE again.
Question: do we need a follow-up to change the package commands as well?

Activated the language and the language switcher in the preferences.

5. Verify that all (templates, sysprefs, xslt, installer files) is
   correctly translated

! System preferences: remained English
Staff GUI: OK
OPAC GUI: OK
XSLT in staff and OPAC: OK
messages JS: OK (verified with OPAC cart strings)
messages: OK (verified with "item" and "items" in staff result list)
installer: OK (tested with es-ES)
installed sample files: OK (tested with notices and frameworks)

Preferences don't translate.
Stopping here for now because of the problem with prefs.

6. Run `gulp po:create --lang <lang>` and verify that it created all PO
   files for that language


7. Run `prove t/misc/translator`

Test Summary Report
-------------------
t/misc/translator/xgettext-pref.t     (Wstat: 3840 Tests: 16 Failed: 15)
  Failed tests:  1, 3-16
  Non-zero exit status: 15
Files=3, Tests=56,  1 wallclock secs ( 0.03 usr  0.01 sys +  0.34 cusr  0.07 csys =  0.45 CPU)
Result: FAIL
Comment 50 Julian Maurice 2020-08-29 16:20:08 UTC Comment hidden (obsolete)
Comment 51 Julian Maurice 2020-08-29 16:20:12 UTC Comment hidden (obsolete)
Comment 52 Julian Maurice 2020-08-29 16:20:16 UTC Comment hidden (obsolete)
Comment 53 Julian Maurice 2020-08-29 16:36:09 UTC
(In reply to Katrin Fischer from comment #49)
> 1. Run `yarn install` and install Locale::XGettext::TT2
> 
> It looks like Locale::XGettext::TT2 has no packages for Debian yet, can you
> confirm?
That's true. It is not packaged in Debian.

> 3. Verify the contents of updated PO files
> 
> I have verified the contents of the de-DE files. 
> 
> Problem: It appears that a strings have jumped from one po file to another,
> requiring a lot of retranslations. Namely this seems to be the value_builder
> plugins that are no longer in the MARC flavor files but appear in staff now:
> 
> Example string:
> twentyfour track
> 
> This is now in the UNIMARC file, but with this patch appears in staff.
Good catch! Thanks :)
It seems that the update to gulp v4 has some issues with file globs and case-sensitivity. Fixed in one of the latest patches

I compared the number of msgid before and after the patch:

Before:
  de-DE-installer-MARC21.po 1738
  de-DE-installer.po 754
  de-DE-marc-MARC21.po 3152
  de-DE-marc-NORMARC.po 449
  de-DE-marc-UNIMARC.po 1797
  de-DE-messages-js.po 80
  de-DE-messages.po 25
  de-DE-opac-bootstrap.po 2014
  de-DE-pref.po 2538
  de-DE-staff-prog.po 9705
After:
  de-DE-installer-MARC21.po 1738
  de-DE-installer.po 754
  de-DE-marc-MARC21.po 3154   # 2 additional strings picked from koha-tmpl/intranet-tmpl/prog/en/data/marc21_field_CF.xsd, can be excluded if needed
  de-DE-marc-NORMARC.po 449
  de-DE-marc-UNIMARC.po 1797
  de-DE-messages-js.po 80
  de-DE-messages.po 27   # 2 additional strings picked, thanks to the transition to Locale::XGettext::TT2
  de-DE-opac-bootstrap.po 2014
  de-DE-pref.po 2538
  de-DE-staff-prog.po 9705

> Question: Reviewing the pref po looks like before, correct?
Yes, the pref po file content should not change (except for long lines wrapping, and maybe the order of strings ? I did not check)

> 4. Run `cd misc/translator && ./translate install <lang>`
> 
> Testing with de-DE again.
> Question: do we need a follow-up to change the package commands as well?
I haven't tested those, but I don't think a change is needed

> Activated the language and the language switcher in the preferences.
> 
> 5. Verify that all (templates, sysprefs, xslt, installer files) is
>    correctly translated
> 
> ! System preferences: remained English
> Staff GUI: OK
> OPAC GUI: OK
> XSLT in staff and OPAC: OK
> messages JS: OK (verified with OPAC cart strings)
> messages: OK (verified with "item" and "items" in staff result list)
> installer: OK (tested with es-ES)
> installed sample files: OK (tested with notices and frameworks)
> 
> Preferences don't translate.
> Stopping here for now because of the problem with prefs.
Fixed by the last patch

> 7. Run `prove t/misc/translator`
> 
> Test Summary Report
> -------------------
> t/misc/translator/xgettext-pref.t     (Wstat: 3840 Tests: 16 Failed: 15)
>   Failed tests:  1, 3-16
>   Non-zero exit status: 15
> Files=3, Tests=56,  1 wallclock secs ( 0.03 usr  0.01 sys +  0.34 cusr  0.07
> csys =  0.45 CPU)
> Result: FAIL
Fixed

Thank you Katrin for testing !
It's now ready to be tested again :)
Comment 54 Katrin Fischer 2020-09-12 22:49:28 UTC
Hm, having problems applying this patch set:

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 25067: Move PO file manipulation code into gulp tasks
Using index info to reconstruct a base tree...
M	gulpfile.js
M	package.json
M	t/LangInstaller.t
M	yarn.lock
Falling back to patching base and 3-way merge...
Auto-merging yarn.lock
CONFLICT (content): Merge conflict in yarn.lock
Auto-merging t/misc/translator/sample.tt
CONFLICT (modify/delete): t/LangInstaller.t deleted in Bug 25067: Move PO file manipulation code into gulp tasks and modified in HEAD. Version HEAD of t/LangInstaller.t left in tree.
Auto-merging package.json
CONFLICT (content): Merge conflict in package.json
Auto-merging gulpfile.js
error: Failed to merge in the changes.
Patch failed at 0001 Bug 25067: Move PO file manipulation code into gulp tasks
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-25067-Move-PO-file-manipulation-code-into-gulp-ejV37B.patch

Can you please check?
Comment 55 Julian Maurice 2020-09-13 11:40:52 UTC Comment hidden (obsolete)
Comment 56 Julian Maurice 2020-09-13 11:40:58 UTC Comment hidden (obsolete)
Comment 57 Julian Maurice 2020-09-13 11:41:04 UTC Comment hidden (obsolete)
Comment 58 Julian Maurice 2020-09-13 11:41:11 UTC Comment hidden (obsolete)
Comment 59 Julian Maurice 2020-09-13 11:41:19 UTC Comment hidden (obsolete)
Comment 60 Julian Maurice 2020-09-13 11:41:27 UTC Comment hidden (obsolete)
Comment 61 Julian Maurice 2020-09-13 11:41:34 UTC Comment hidden (obsolete)
Comment 62 Julian Maurice 2020-09-13 11:41:42 UTC Comment hidden (obsolete)
Comment 63 Julian Maurice 2020-09-13 11:41:50 UTC Comment hidden (obsolete)
Comment 64 Julian Maurice 2020-09-13 12:24:58 UTC
Patches rebased on master
Comment 65 Martin Renvoize (ashimema) 2020-09-25 14:31:17 UTC
I think I follow Julians thinking here.. the create and update process's are at the developer level and should always take place from a source directory.

We should strongly discourage people from updating live code in /usr/share/koha etc and so I agree with dropping the ability to run the, now gulp tasks, from a live install... 

As far as I understand, everything basically continues to work as they always did (especially with the backward compatable calls inside translate).

I think it's clearer to developers and end users having the distinct processes myself.. one for creating and maintaining translations (via gulp tasks) and a second for 'installing' and 'using' translations from the scripts.
Comment 66 Julian Maurice 2020-09-26 08:18:21 UTC Comment hidden (obsolete)
Comment 67 Julian Maurice 2020-09-26 08:19:15 UTC
Squashed all patches
Comment 68 Katrin Fischer 2020-10-14 21:22:11 UTC
Created attachment 111642 [details] [review]
Bug 25067: Move PO file manipulation code into gulp tasks

misc/translator/translate was doing three different things:
- extract translatable strings
- create or update PO files
- install translated templates

This patch separates responsibilities by moving the string extraction
code into several 'xgettext-like' scripts and adds gulp tasks to
automate string extraction and PO files update

This has several benefits:

- gulp runs tasks in parallel, so it's a lot faster (updating all PO
  files is at least 10 times faster with my 4-cores CPU)

- there is no need for $KOHA_CONF to be defined
  LangInstaller.pm relied on $KOHA_CONF to get the different paths
  needed. I'm not sure why, since string extraction and PO update should
  work on source files, not installed files

- string extraction code can be more easily tested

This patch also brings a couple of fixes and improvements:

- TT string extraction (strings wrapped in [% t(...) %]) was done with
  Template::Parser and PPI, which was extremely slow, and had some
  problems (see bug 24797).
  This is now done with Locale::XGettext::TT2 (new dependency) which is
  a lot faster, and fixes bug 24797

- Fix header in 4 PO files

For backward compatibility, 'create' and 'update' commands of
misc/translator/translate can still be used and will execute the
corresponding gulp task

Test plan:
1. Run `yarn install` and install Locale::XGettext::TT2
2. Run `gulp po:update`
3. Verify the contents of updated PO files
4. Run `cd misc/translator && ./translate install <lang>`
5. Verify that all (templates, sysprefs, xslt, installer files) is
   correctly translated
6. Run `gulp po:create --lang <lang>` and verify that it created all PO
   files for that language
7. Run `prove t/misc/translator`

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Need to install yarn & gulp, no errors

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 69 Katrin Fischer 2020-10-14 21:22:19 UTC
Created attachment 111643 [details] [review]
Bug 25067: (QA follow-up) Add +x on test files

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 70 Katrin Fischer 2020-10-14 21:25:29 UTC
I am passing QA here, but there are some caveats:

1) This adds a dependency on Locale::XGettext::TT2 that currently has no packages for Debian. 

2) The second part that deals with the translations of system preferences on bug 26547 is not ready yet. I believe both patches should only be pushed together. 

I hope that moving this a step further will be a little push for things to be finished. The other option would be moving it into BLOCKED (leaving that to RM)
Comment 71 Julian Maurice 2020-10-15 06:30:06 UTC
(In reply to Katrin Fischer from comment #70)
> 2) The second part that deals with the translations of system preferences on
> bug 26547 is not ready yet. I believe both patches should only be pushed
> together. 

Why ? Translations of system preferences still work without bug 26547. I moved the sysprefs part to bug 26547 for the specific purpose of not blocking this one :-)
Comment 72 Katrin Fischer 2020-10-15 08:55:52 UTC
(In reply to Julian Maurice from comment #71)
> (In reply to Katrin Fischer from comment #70)
> > 2) The second part that deals with the translations of system preferences on
> > bug 26547 is not ready yet. I believe both patches should only be pushed
> > together. 
> 
> Why ? Translations of system preferences still work without bug 26547. I
> moved the sysprefs part to bug 26547 for the specific purpose of not
> blocking this one :-)

 Maybe this is a misunderstanding then. I'll retest, but what shoudl the pref file look like with only this patch?
Comment 73 Julian Maurice 2020-10-15 09:19:51 UTC
(In reply to Katrin Fischer from comment #72)
>  Maybe this is a misunderstanding then. I'll retest, but what shoudl the
> pref file look like with only this patch?

It should look exactly the same, so something like this:

    # Accounting > Policy
    msgid "accounting.pref#FinePaymentAutoPopup# automatically display "
    "a print dialog for a payment receipt when making a payment.."
Comment 74 Jonathan Druart 2020-11-05 08:58:43 UTC
Mason, Could you have a look at how hard/easy Locale::XGettext::TT2 can be packaged (from 20.11 ideally)?
Comment 75 Julian Maurice 2020-11-05 10:43:07 UTC
(In reply to Jonathan Druart from comment #74)
> Mason, Could you have a look at how hard/easy Locale::XGettext::TT2 can be
> packaged (from 20.11 ideally)?

Should it be packaged ? It is a dev-only dependency, so it won't be used in a production environment.
Still better to have it as a deb package, but not required IMO.
Comment 76 Jonathan Druart 2020-11-06 09:38:16 UTC
(In reply to Julian Maurice from comment #75)
> (In reply to Jonathan Druart from comment #74)
> > Mason, Could you have a look at how hard/easy Locale::XGettext::TT2 can be
> > packaged (from 20.11 ideally)?
> 
> Should it be packaged ? It is a dev-only dependency, so it won't be used in
> a production environment.
> Still better to have it as a deb package, but not required IMO.

Debian packages provide a koha-translate command that remove then install for update. So we are good indeed.
Comment 77 Jonathan Druart 2020-11-06 09:44:32 UTC
koha-testing-docker related issue: https://gitlab.com/koha-community/koha-testing-docker/-/issues/233
Comment 78 Jonathan Druart 2020-11-06 14:19:55 UTC
t/misc/translator/xgettext-tt2.t ................. Can't locate Locale/XGettext/TT2.pm in @INC (you may need to install the Locale::XGettext::TT2 module) (@INC contains: /kohadevbox/koha /kohadevbox/qa-test-tools /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl/5.28/parent.pm line 16.
BEGIN failed--compilation aborted at /kohadevbox/koha/t/misc/translator/../../../misc/translator/xgettext-tt2 line 27.

This will be a problem for Mason, if the non db dependent tests fail.
Comment 79 Jonathan Druart 2020-11-06 14:31:38 UTC
Created attachment 113252 [details] [review]
Bug 25067: Move the tests to db_dependent

To not break the package workflow
Comment 80 Jonathan Druart 2020-11-06 14:56:12 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 81 Jonathan Druart 2020-11-06 16:00:12 UTC
Created attachment 113255 [details] [review]
Bug 25067: Adjust paths in tests
Comment 82 Jonathan Druart 2020-11-06 16:00:25 UTC
Silly me...
Comment 83 Jonathan Druart 2020-11-06 16:07:05 UTC
Created attachment 113258 [details] [review]
Bug 25067: Fix perlcritic errors
Comment 84 Jonathan Druart 2020-11-06 16:15:16 UTC
Julian, we have xt/author/translatable-templates.t that is failing.

kohadev-koha@kohadevbox:/kohadevbox/koha$ prove xt/author/translatable-templates.t 
xt/author/translatable-templates.t .. 1/? 
#   Failed test 'opac_bootstrap templates are translatable'
#   at xt/author/translatable-templates.t line 91.
# Unknown action specified.
# 
# Try `./tmpl_process3.pl --help for more information.
# 

#   Failed test 'staff_prog templates are translatable'
#   at xt/author/translatable-templates.t line 91.
# Unknown action specified.
# 
# Try `./tmpl_process3.pl --help for more information.
# 
# Looks like you failed 2 tests of 2.

Any ideas how we could fix that elegantly?
Comment 85 Julian Maurice 2020-11-06 17:53:53 UTC
I tried to go back to just before these patches to make xt/author/translatable-templates.t fail, unsuccessfully. I'm not sure what this script is supposed to test, because even with a completely broken template with invalid html and invalid TT markup, the tests pass.
So it looks like the test is useless, and I suggest to remove it.
Comment 86 Mason James 2020-11-09 08:06:43 UTC
(In reply to Julian Maurice from comment #75)
> (In reply to Jonathan Druart from comment #74)
> > Mason, Could you have a look at how hard/easy Locale::XGettext::TT2 can be
> > packaged (from 20.11 ideally)?
> 
> Should it be packaged ? It is a dev-only dependency, so it won't be used in
> a production environment.
> Still better to have it as a deb package, but not required IMO.

i've added a package for Locale::XGettext::TT2 to the koha-staging repo

fyi, Locale::XGettext::TT2 0.7 requires a new version of libintl-perl(1.30) to be built for each(16) debian/ubuntu release, so i've gone with 0.6 as a workaround


$ apt-cache policy  libtemplate-plugin-gettext-perl
libtemplate-plugin-gettext-perl:
  Installed: 0.6-1~koha1
  Candidate: 0.6-1~koha1
  Version table:
 *** 0.6-1~koha1 500
        500 http://debian.koha-community.org/koha-staging dev/main amd64 Packages
        100 /var/lib/dpkg/status

$ dpkg -L  libtemplate-plugin-gettext-perl
/.
/usr
/usr/bin
/usr/bin/xgettext-tt2
/usr/share
/usr/share/doc
/usr/share/doc/libtemplate-plugin-gettext-perl
/usr/share/doc/libtemplate-plugin-gettext-perl/NEWS.gz
/usr/share/doc/libtemplate-plugin-gettext-perl/bugs-1.tt
/usr/share/doc/libtemplate-plugin-gettext-perl/bugs.t
/usr/share/doc/libtemplate-plugin-gettext-perl/changelog.Debian.gz
/usr/share/doc/libtemplate-plugin-gettext-perl/changelog.gz
/usr/share/doc/libtemplate-plugin-gettext-perl/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/xgettext-tt2.1p.gz
/usr/share/man/man3
/usr/share/man/man3/Locale::XGettext::TT2.3pm.gz
/usr/share/man/man3/Template::Plugin::Gettext.3pm.gz
/usr/share/perl5
/usr/share/perl5/Locale
/usr/share/perl5/Locale/XGettext
/usr/share/perl5/Locale/XGettext/TT2.pm
/usr/share/perl5/Locale/XGettext/TT2.pod
/usr/share/perl5/Template
/usr/share/perl5/Template/Plugin
/usr/share/perl5/Template/Plugin/Gettext.pm
/usr/share/perl5/Template/Plugin/Gettext.pod
Comment 87 Jonathan Druart 2020-11-09 10:20:34 UTC
(In reply to Julian Maurice from comment #85)
> I tried to go back to just before these patches to make
> xt/author/translatable-templates.t fail, unsuccessfully. I'm not sure what
> this script is supposed to test, because even with a completely broken
> template with invalid html and invalid TT markup, the tests pass.
> So it looks like the test is useless, and I suggest to remove it.

Same here, I decided to remove the file on bug 26971.
Comment 88 Jonathan Druart 2020-11-09 10:45:14 UTC
(In reply to Jonathan Druart from comment #81)
> Created attachment 113255 [details] [review] [review]
> Bug 25067: Adjust paths in tests

(In reply to Jonathan Druart from comment #83)
> Created attachment 113258 [details] [review] [review]
> Bug 25067: Fix perlcritic errors

Last 2 patches pushed to master for 20.11.
Comment 89 Lucas Gass (lukeg) 2020-11-16 22:16:28 UTC
enhancement will not be backported to 20.05.x