makemessages - Add an option to disable fuzzy translations?

1,561 views
Skip to first unread message

אורי

unread,
Jan 11, 2019, 1:46:04 AM1/11/19
to django-d...@googlegroups.com

I also don't like the "fuzzy" keyword and I spent hours in deleting them from our django.po files after running makemessages. I would like to disable them completely since they don't make sense in our project. Every time after running makemessages I have to search for the "fuzzy" keywords, delete them and also delete translations which are incorrect. I would like all the translations to be blank if not exactly translated.

I didn't understand what you mean by "msgmerge with the "-N" option swiches off fuzzy-matching.".

By the way, is it possible to add a default keyword that will be used for all new translations instead of "" in a specific language? For example "TODO"? Because I don't want to forget to translate them. Currently I have to search and manually replace "" with "TODO". And by the way the string "" appears also with translated texts.

Thanks,
אורי (Uri)

Claude Paroz

unread,
Jan 11, 2019, 3:10:06 AM1/11/19
to Django developers (Contributions to Django itself)
Le vendredi 11 janvier 2019 07:46:04 UTC+1, Uri Even-Chen a écrit :

I also don't like the "fuzzy" keyword and I spent hours in deleting them from our django.po files after running makemessages.

Hi Uri,

Create your own makemessages command and provide your custom msgmerge_options. Something like:

from django.core.management.commands.makemessages import Command as MakeMessagesCommand

class Command(MakeMessagesCommand):
    msgmerge_options = ['-q', '--previous', '--no-fuzzy-matching']

As for your second question, your should use a dedicated tool to translate messages (poedit, gtranslator, virtaal, lokalize, etc.), so you won't have to search for untranslated messages yourself. Even text editors like vim or emacs provide po mode translations.

HTH,

Claude

Sjoerd Job Postmus

unread,
Jan 11, 2019, 3:47:00 AM1/11/19
to django-d...@googlegroups.com

Regarding the "default keyword TODO": there are tools that can be used for working with translations, in the gettext suite.


For instance, for a given django.po file, the following command prints all untranslated strings:


    msgattrib --untranslated path/to/django.po


We have the following command somewhere in a wiki:


    for k in */locale/*/LC_MESSAGES/django.po; do echo $(msgattrib --untranslated $k | grep msgstr | wc -l) $k; done | grep -v '^0 ' | sort -n

which prints the files with missing translations, together with how many translations are missing.



Unrelated tips for makemessages, but if you start overriding makemessages, good extra flags would be:

* just hard-code `no_location` to True. It makes the generated .po-file non-stable when adding even 1 extra line in the source file.

* same for hard-coding `no_wrap` to be honest, *or* the line-width.

* "--sort-output" (for msgmerge and msgattrib), so that the generated .po-file is stable, even when the code itself has been moved around.

* add the flag "--keyword=_l", so that you can use `_l` instead of `gettext_lazy`, but that's depending on taste.

Regards,

Sjoerd Job

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CABD5YeHU68Vr9M%2BMCvb3DiJYUpBUaO2PJuEpXb%3DctqE1HJX4fQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

אורי

unread,
Jan 14, 2019, 11:04:29 PM1/14/19
to django-d...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
Reply all
Reply to author
Forward
0 new messages