A very strange behavior appears to happen in my django project.
I marked every important string in my project as translatable with ugettext_lazy like in the documentation
When I'm using these variables in my templates some of them are translated, with the matching string from the translation-file but others don't.
I also tried the instructions and hints given in How to setup up Django translation in the correct way? and https://docs.djangoproject.com/en/dev/topics/i18n/translation/#how-django-discovers-language-preference
I also tried to switch a bit around between ugettext and ugettext_lazy to see some effect.
I ran
python manage.py compilemessages -a -l de -v3
python manage.py compilemessages
after each time I tries something else.
THe effect is still present, that the first few entries that are used in views and templates are translated probably but every entry after the first message string that appears only in a python file is not translated. regardless if it appears to be in a template, a python file or both.
Example:
#: backend/forms.py:18 backend/views.py:129 backend/views.py:134
#: backend/views.py:1274 backend/views.py:1275
#: backend/templates/backend/index.html:31
msgid "username"
msgstr "Benutzername"
#: backend/forms.py:19 core/templates/core/tables/employees_table.html:6
msgid "first name"
msgstr "Vorname"
#: backend/forms.py:20 core/templates/core/tables/employees_table.html:7
msgid "last name"
msgstr "Nachname"
#: backend/forms.py:21
msgid "mail address"
msgstr "E-Mailadresse"
So username, first name, last name are translated perfectly according to my browser-settings, but mail address isn't translated, even if it is used in a simple string in the template like {% trans "mail address" %} (right asides of {% trans "username" %})
Because of the working translations for the first two strings I assume, that the error is not somewhere in my settings.
ugettext_lazyfor everything that is executed at module load time like models and forms fields definitions etc - cf docs.djangoproject.com/en/dev/topics/i18n/translation/…. If you import aliasugettextorugettext_lazyto_()(which is a common practice, make sure you don't rebind this name later. Also remember that you have to restart your server after the call tocompilemessages. Finally, check for fuzzy translations in your translation files - fuzzy translations are in fact not translated. - bruno desthuilliers