Hey Marc,

On 3/11/25 12:03 PM, Marc Haber wrote:
Basically the same applies for this step than for the POT generation
step, with the additional hardship that the PO files are generated,
being written to by a program AND STILL contain a significant part of
human work. I never know how much work of other people I am destroying
by calling msgmerge out of line. In which stage of package build do I do
msgmerge? Do I commit the merged po files, when do I commit them, what
do I do with them during git merge when a feature branch is merged?

I have a bit played around with `msgmerge` and found a way to display
a `diff` which contains the translations which will be destroyed if
you merge a .po file from a translator

  * test-de_DE-transl.po

into your maintained one

  * test-de_DE.po

in conjunction with the current generated .pot file

  * test.pot

The essential code snippet looks like this

**********************************************************************
*
* msgmerge -q -C test-de_DE-transl.po test-de_DE.po test.pot \
*   > test-de_DE-maint+transl.po
* msgmerge -vv -q -C test-de_DE.po test-de_DE-transl.po test.pot \
*   > test-de_DE-transl+maint.po
*
* # Print out the new merged .po file
* cat test-de_DE-transl+maint.po
*
* # Show the diff of destroyed translations (including comments)
* diff -u test-de_DE-maint+transl.po test-de_DE-transl+maint.po
*
**********************************************************************

The order of the `msgid`s are not necessary in the .po files and will
be defined in the .pot file.  Also comments and headers diffs will be
printed out.

For all of my test cases (I could imagine) it works very well.  You
can try it out: I put an example implementation in a Makefile and put
it together with a small test-translation into a tarball attachmented
to this email.  You just need to run

  $> make all

With `make clean` you can delete the two temporary files.  The output
of the makefile in the tarball is appended to this email.

Hopefully it helps for progression,
Dirk =)


**********************************************************************
* msgmerge-show-overridden.tar.gz
*
* Begin of output
**********************************************************************

make all
msgmerge -q -C test-de_DE-transl.po test-de_DE.po test.pot > test-de_DE-maint+transl.po msgmerge -vv -q -C test-de_DE.po test-de_DE-transl.po test.pot > test-de_DE-transl+maint.po
test.pot:11: this message is used but not defined in test-de_DE-transl.po
test.pot:32: this message is used but not defined...
test-de_DE-transl.po:21: ...but this definition is similar
Read 1 old + 1 reference, merged 9, fuzzied 1, missing 1, obsolete 1.

New test-de_DE.po
************************

cat test-de_DE-transl+maint.po
msgid ""
msgstr ""
"Language: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: PhraseApp (phraseapp.com)\n"

msgid "boolean_key"
msgstr ""

msgid "pluralized_key"
msgid_plural ""
msgstr[0] ""
msgstr[1] ""

# Translator: Overridden comment
msgid "key_with_description"
msgstr ""

msgid "empty_string_translation"
msgstr ""

msgid "nested.key"
msgstr "Fuzzy"

msgid "null_translation"
msgstr ""

#, fuzzy
msgid "nested.deeply.key"
msgstr "Fuzzy"

msgid "sample_collection"
msgstr ""

msgid "unverified_key"
msgstr ""

msgid "simple_key"
msgstr "Einfacher Translator Stirng"

Overridden by translator
************************

diff -u test-de_DE-maint+transl.po test-de_DE-transl+maint.po || true
--- test-de_DE-maint+transl.po  2025-03-19 14:52:18.567974496 +0100
+++ test-de_DE-transl+maint.po  2025-03-19 14:52:18.571974539 +0100
@@ -4,7 +4,7 @@
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=3; plural=(n > 2);\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
 "X-Generator: PhraseApp (phraseapp.com)\n"

 msgid "boolean_key"
@@ -15,7 +15,7 @@
 msgstr[0] ""
 msgstr[1] ""

-# Maintainer: I'm a very important description for this key!
+# Translator: Overridden comment
 msgid "key_with_description"
 msgstr ""

@@ -39,4 +39,4 @@
 msgstr ""

 msgid "simple_key"
-msgstr "Einfacher Maintainer Stirng"
+msgstr "Einfacher Translator Stirng"

**********************************************************************
* End of output
*
* msgmerge-show-overridden.tar.gz
**********************************************************************

Attachment: msgmerge-show-overridden.tar.gz
Description: application/gzip

Attachment: OpenPGP_0xE2A3766F21F02BD5.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to