From bfa3014be4b753bbc338e67163a2138a35bfe9c9 Mon Sep 17 00:00:00 2001 From: Laouen Fernet Date: Sat, 18 Apr 2020 15:29:50 +0200 Subject: [PATCH] Add information about fuzzy and obsolete entries --- Dev-Documentation/Translation.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Dev-Documentation/Translation.md b/Dev-Documentation/Translation.md index 266fec7..969267f 100644 --- a/Dev-Documentation/Translation.md +++ b/Dev-Documentation/Translation.md @@ -1,4 +1,4 @@ -This page explains how to mark strings and how to translate them. It is quite concise, and developers are invited to refer to the [offical documentation from Django](https://docs.djangoproject.com/en/3.0/topics/i18n/translation/) or ask questions to other project members to get more details (e.g. plural forms). +This page explains how to mark strings and how to translate them. It is quite concise, and developers are invited to refer to the [official documentation from Django](https://docs.djangoproject.com/en/3.0/topics/i18n/translation/) or ask questions to other project members to get more details (e.g. plural forms). Strings should be written in English as this is the language of the Re2o project. Any string that can be displayed to a user needs to be marked for translation. Developers have to mark the strings for translation when they write new code. Then, either they do the translation themselves or they contact another project member to translate. @@ -86,6 +86,29 @@ msgstr "Et pourtant elle tourne" ``` As mentioned earlier, a translator only edits the `msgstr` part. The `msgid` and the comments above are generated automatically, please refer to the previous step if you need to make corrections to strings present in the code. +One thing that can occur after updating message files that already contained translations is the presence of *fuzzy* entries. They look like this: +``` +#: path/to/file:1000 +#, fuzzy +msgid "And yet it moves" +msgstr "Et pourtant elle tourne" +``` +Primarily this shows that the original string in English was modified, and that the translator should maybe change the translation. Edit the translation if necessary and remove the *fuzzy* attribute when you are satisfied. +If you do not know what to do at all, you should look up the occurrence of the string in the code file (given by the first comment, file location and line number). Then make sure that the string is as it should be in English and run `makemessages`. Then check fuzzy entries and consider two options: +- Remove the *fuzzy* attribute by deleting the line, if the rest looks correct (in particular verify that the `msgid` string is the same one as in the code). Future generation of message files should not add *fuzzy* to that entry anymore. +- Remove the whole entry by deleting the few lines. It will be added automatically when generating the message files again. If you have no translation, just remove the entry. Otherwise if you have a translation, try the other option. + +Once you corrected fuzzy entries, run again the `makemessages` command. Fill translations if needed, check that there are no fuzzy entries. + +Another thing worth mentioning is that if you delete strings in the code, the translation is not removed from the message file but only commented out (at the bottom of the file) when generating the message file again. These comments are called obsolete entries. This can either mean that the original string was deleted in the code file and then you can remove the whole comment, or that the string was modified but the command did not successfully saw that it was the same string. Then make sure that the correct translation is present in the message file, and finally you can remove the comment afterwards. + +For easy tracking of fuzzy entries or untranslated strings, you can use the following commands: +``` +$ msgattrib --only-fuzzy app_name/locale/fr/LC_MESSAGES/django.po +$ msgattrib --untranslated app_name/locale/fr/LC_MESSAGES/django.po +``` +Help for `msgattrib` can be found in the [`gettext` utilities documentation](https://www.gnu.org/software/gettext/manual/gettext.html#msgattrib-Invocation). + ## Compiling message files The message files are not actually used to display translations. They need to be compiled in .mo files, which are more efficiently accessed by the server. Once the translations are satisfying, run this command: