Working with Django, you can use django.utils.translation.ugettext
and ....ugettext_lazy
(as well as some template tags) to handle translation of localized messages.
Later, with command: django-admin.py makemessages -l <LANGUAGE>
you can generate the po
file containing the original string, so that the developer can specify the desired translation.
Question: is there a django command, or any other quick way, to find out which messages have not been translated?
Usually I look for the string msgstr ""
in the po
file, but that's inaccurate, since some translations are multiline, like the following:
#file.py:xyz
msgid ""
"Some very long text"
msgstr ""
"The translation of some very long text"
Thus, looking for msgstr ""
I get "false positives" (i.e. strings that are actually translated, but whose translation start the next line). With thousand of lines, this quite often.
Any smart suggestion?
Thanks
Assuming you are using some popular editors:
msgstr ""\n\n
msgstr ""\r\n\r\n
sed -i '/msgstr ""/{N;N; s/\n\n/\n# translate me!\n\n/g}' django.po
and then search for # translate me!
comments in the file.You can use
msgfmt --statistics --output=/dev/null locale/django.po
to see how many missing translations there are (if any), and
msgattrib --untranslated locale/fr/LC_MESSAGES/django.po
to list the untranslated messages.
The easiest way to check for missing translations, and other errors, would be to use the "msgcmp" utility. It's actually supposed to be used to compare a translations file (.po) against a template (.pot), but it's perfectly happy to compare a .po file against itself:
msgcmp path/to/nl.po path/to/nl.po
will do the trick, and even fail if any translations are marked as fuzzy (unless you specify --use-fuzzy).
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