]> git.koha-community.org Git - koha.git/commit
Bug 25067: Move PO file manipulation code into gulp tasks
authorJulian Maurice <julian.maurice@biblibre.com>
Sun, 29 Mar 2020 12:56:20 +0000 (14:56 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 6 Nov 2020 08:46:11 +0000 (09:46 +0100)
commit3cfc2ec7bd1becef4386404fe7fc9f12740e8c97
tree4d78b97b1685dc1fc996a22653d0db86cdc0a88b
parentd5d736909ccd24b38e90e89b1484da73972d8645
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>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
24 files changed:
cpanfile
docs/development/internationalization.md [new file with mode: 0644]
gulpfile.js
misc/translator/LangInstaller.pm
misc/translator/po/dz-pref.po
misc/translator/po/gd-pref.po
misc/translator/po/lv-pref.po
misc/translator/po/te-pref.po
misc/translator/tmpl_process3.pl
misc/translator/translate
misc/translator/xgettext-installer [new file with mode: 0755]
misc/translator/xgettext-pref [new file with mode: 0755]
misc/translator/xgettext-tt2 [new file with mode: 0755]
misc/translator/xgettext.pl
package.json
t/LangInstaller.t [deleted file]
t/LangInstaller/templates/simple.tt [deleted file]
t/misc/translator/sample.pref [new file with mode: 0644]
t/misc/translator/sample.tt [new file with mode: 0644]
t/misc/translator/sample.yml [new file with mode: 0644]
t/misc/translator/xgettext-installer.t [new file with mode: 0644]
t/misc/translator/xgettext-pref.t [new file with mode: 0644]
t/misc/translator/xgettext-tt2.t [new file with mode: 0755]
yarn.lock