Hello Thomas, Am Do., 31. Dez. 2020 um 15:39 Uhr schrieb Thomas Vincent <tho...@vinc-net.fr>: > > Hello Mario, > > Le 31/12/2020 à 10:02, Mario Blättermann a écrit : > > In general, it would be very helpful if the committer of a .po file > > would run the script use-for-compendium.sh for that file. This way the > > translation can be written back to other .po files, which saves time. > > But before committing such changes, always run »git diff« to see what > > would be changed. > > Could this be done automatically in a git hook? > > I would see something like this: > - The translator changes a .po file and commits it. > - The git hook (pre-commit, probably) runs use-for-compendium.sh. > - If the script didn't change anything, the commit goes on. Otherwise, > the commit is stopped and a message is displayed to advise the > translator to add the changed files. > > What would you think about this? > First, let's have a look at the desired workflow:
Once someone is finished with translating and/or reviewing a .po file, it gets committed into the Git repo. If this file contains some Gettext message which appears more than once in the .po file collection, that message is also to find somewhere in the compendium files. There are two possible cases: In the first case, the message in question is already translated somewhere - and also translated in the compendium. If the recently changed .po file contains a new version of that message (wording, formatting etc. have been changed), then this new message in the .po file gets overwritten with the older version from the compendium next time someone runs update-po.sh, either explicitely or through another script like update-translations.sh. The updates and the review of the .po file would become useless. That's why it is needed to run »./use-for-compendium.sh man?/filename.po« to overwrite the compendium. In the second case, the message is part of the compendium, but still untranslated or »fuzzy« there. If someone runs ./use-for-compendium.sh, the message will be added to the compendium and next time someone runs ./update-translations.sh, it will be written back to all .po files where it appears - maybe lots of files would benefit of it. In fact, it's what I do when I update the .po files from recently downloaded upstream packages: After running ./update-common.sh in each of the language directories, I have a look at the compendium files, especially common/min-100-occurences.po. After an upstream update of the »manpages« and »manpages-dev« packages, in a few messages only the version number has been changed, for example 5.09 to 5.10 some days ago. Then I fix this, remove the »fuzzy« tag, and hundreds of files benefit of this simple change when I run ./update-translations.sh. So let me summarize: It is urgently recommended to run ./use-for-compendium.sh after changing a .po file. Back to the Git hook question. As far as I can evaluate, it would be not very helpful, because the effect of use-for-compendium.sh always should be reviewed by running »git diff«. In some cases, the things added to compendium are ambiguous. In such cases, the Gettext message in question needs to be added to templates/exclude.pot, as described in CONTIBUTING.md. Anyway, if you like to run the script automatically, do it at your own risk. Best Regards, Mario