With gettext, the original (usually English) text of messages serves as the message key ("msgid") for the translations. This means that every time the original text changes, the msgid must be updated in all the .po files.
For real changes of the text, this is obviously unavoidable, as the translator must update the translation.
However, if the change of the original does not change its meaning, re-translation is superflous (e.g. change in punctation, whitespace changes, or correction of a spelling mistake).
Is there a way to update the .po files automatically in that case?
I tried to use xgettext & msgmerge (with fuzzy matching turned on), but fuzzy matching sometimes fails, plus this produces lots of ugly "#,fuzzy" flags.
Note: There is a similar question: How to efficiently work with gettext PO files when making small edits to large text values However, it's about large strings, thus about a more specific problem.
One way to avoid the problem is to leave the msgids alone, have a .po file for the original language and make the fix inside that.
It always strikes me as being more of a work around than a proper fix though. For the next iteration (where there will definitely be more msgid changes) the msgid is changed and either the translators translate it in their usual update or each language is updated by hand when the msgid is changed.
I've had exactly this issue when doing minor changes to a django project. What I do is the following:
If I have done things right, the last step is superflous (i.e, you have done the change for gettext). django uses the gettext utilities, so it shouldn't matter how you make your message files.
I find and replace like so:
find . -name "*.po" -print | xargs sed -i 's/oldmessageid/newmessageid/g'
Courtesy of http://rushi.vishavadia.com/blog/find-replace-across-multiple-files-in-linux
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With