Translation ignored / not loaded

Hi,
I am trying to translate my Django project in Norwegian Bokmål (code “nb”), but when I open the admin interface the Django admin strings are shown in Norwegian, while my strings are shown in English, even if I created a .po file, generated a .mo file, the locale middleware is on and the other settings seems fine. Funny thing is that if I set LANGUAGE_CODE to ‘nb’ then the whole interface is in Norwegian.

Why does it seems that Django is ignoring my translated string? How to debug that, given that I have no error at all?

Thanks for your help!

Hi frafra,
make sure you are using ugettext_lazy instead of ugettext for your translations, it seems like django translates strings with gettext before getting to know the actual locale. So forcing LANGUAGE_CODE works because it will cache the translation in your default language.

Hope this may help!
Bye

1 Like

That was it! Thank you :slight_smile: