Bug 35342

Summary: Use a Makefile to manage PO files
Product: Koha Reporter: Julian Maurice <julian.maurice>
Component: I18N/L10NAssignee: Julian Maurice <julian.maurice>
Status: Patch doesn't apply --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: f.demians, jonathan.druart, paul.derscheid
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 35342: Use a Makefile to manage PO files
Bug 35342: Use a Makefile to manage PO files

Description Julian Maurice 2023-11-15 13:58:14 UTC

    
Comment 1 Julian Maurice 2023-11-15 13:59:08 UTC
Created attachment 158981 [details] [review]
Bug 35342: Use a Makefile to manage PO files

There were some problems recently involving gulp and PO files, which are
still unresolved at the time of writing.
Debugging this is hard and time-consuming (failures are hard to
reproduce)

Why make/a Makefile ?

* Creating/updating PO files is essentially passing a list of input
  files to a command that will produce a new/updated output file, and
  that's exactly what make does
* It builds only what's needed by default (if source files haven't
  changed, no need to rebuild the .pot, and so .po files don't need
  to be updated either)
* It handles parallelism well

To use the Makefile, you need to be at the root directory of Koha, and
then you can run:

make -f misc/translator/Makefile help
    To have a list of available targets

make -f misc/translator/Makefile all
    To update all PO files

make -f misc/translator/Makefile pot
    To rebuild all POT files

make -f misc/translator/Makefile en-GB
    To update all en-GB PO files

make -f misc/translator/Makefile misc/translator/Koha-installer.pot
    To update that particular file

By default, it won't build a target (output file) if its prerequisites
(input files) are older than the target. It can be forced with
-B/--always-make

By default, all targets are built sequentially. To enable parallelism,
use -j/--jobs

Multiple targets can be specified on the command line, so it's possible
to do:

make -f misc/translator/Makefile -j -B en-GB fr-FR

gulpfile.js is updated to uses this Makefile

This patch also includes a fix in Koha/Database/Columns.pm (a translated
empty string caused gettext to emit a warning and to place the header in
the middle of the .po/.pot file)
Comment 2 Julian Maurice 2023-11-15 14:05:07 UTC
In one of the many attempts to find a solution to bug 35332 I tried to use a Makefile instead, and haven't been able to reproduce the problem with it, so.. I guess this is a possible fix ?

Certainly not for 23.11, but I think it's a robust solution for future releases

I compared with podiff2 (https://github.com/eshagh79/podiff2) the produced POT files to what master does and it found no differences (it only compares msgid I think, not comments)
Comment 3 Julian Maurice 2023-11-15 14:33:24 UTC
Created attachment 158992 [details] [review]
Bug 35342: Use a Makefile to manage PO files

There were some problems recently involving gulp and PO files, which are
still unresolved at the time of writing.
Debugging this is hard and time-consuming (failures are hard to
reproduce)

Why make/a Makefile ?

* Creating/updating PO files is essentially passing a list of input
  files to a command that will produce a new/updated output file, and
  that's exactly what make does
* It builds only what's needed by default (if source files haven't
  changed, no need to rebuild the .pot, and so .po files don't need
  to be updated either)
* It handles parallelism well

To use the Makefile, you need to be at the root directory of Koha, and
then you can run:

make -f misc/translator/Makefile help
    To have a list of available targets

make -f misc/translator/Makefile all
    To update all PO files

make -f misc/translator/Makefile pot
    To rebuild all POT files

make -f misc/translator/Makefile en-GB
    To update all en-GB PO files

make -f misc/translator/Makefile misc/translator/Koha-installer.pot
    To update that particular file

By default, it won't build a target (output file) if its prerequisites
(input files) are older than the target. It can be forced with
-B/--always-make

By default, all targets are built sequentially. To enable parallelism,
use -j/--jobs

Multiple targets can be specified on the command line, so it's possible
to do:

make -f misc/translator/Makefile -j -B en-GB fr-FR

gulpfile.js is updated to uses this Makefile

This patch also includes a fix in Koha/Database/Columns.pm (a translated
empty string caused gettext to emit a warning and to place the header in
the middle of the .po/.pot file)
Comment 4 Jonathan Druart 2024-01-04 13:32:26 UTC
Could you consider providing a perl script instead? :)
Comment 5 Julian Maurice 2024-01-04 13:51:31 UTC
(In reply to Jonathan Druart from comment #4)
> Could you consider providing a perl script instead? :)
Why ? I remember we talked about the readability issue on IRC but that can be fixed. Is there something else ?
A Makefile seems like the best tool for this job
Comment 6 Paul Derscheid 2024-09-13 08:02:40 UTC
Could I suggest, that we keep the idea of a Makefile (which I like) but use a more user friendly variant?

Check out just at https://github.com/casey/just. It's portable and the documentation is very good.

It's basically the same thing w/o much of the arcane syntax.
Comment 7 Julian Maurice 2024-09-13 08:44:13 UTC
'just' looks more like a gulp alternative than a make alternative.
It is fairly new (1.0 was released in 2022) and is not packaged in Debian stable. Who knows if it will still be around in 5 years ?
And it looks like it would rebuild everything even if no files changed.

I am curious about what an equivalent justfile would look like, but my preference still goes to make for now.
Comment 8 Paul Derscheid 2024-09-13 09:02:40 UTC
You are right to be sceptical, however just is currently available in sid (unstable) and trixie (testing) repos.

For reference: https://packages.debian.org/search?keywords=just.

I'll try to translate the Makefile into a justfile for a comparison.
Comment 9 Katrin Fischer 2024-09-13 09:06:50 UTC
It's still a new dependency, so please think thoroughly if the benefit is high enough.
Comment 10 Paul Derscheid 2024-09-13 09:16:44 UTC
This is all valid. Let's wait for just to be available in debian stable before thinking of integrating it.

For now I'd like to eradicate gulp completely and thankfully this was the heavy part.

Therefore let's go w/ the Makefile.
Comment 11 Paul Derscheid 2024-09-13 09:21:03 UTC
Sorry, doesn't apply anymore.