I have template with the following:
{% load i18n %}
{% trans "Welcome to my site!" %}
I use RequestContext, have called makemessages, edited .po files and compiled messages, but everything is not translated, I just see the same message even when I load the page.
Extract from .po file
msgid "Welcome to my site!"
msgstr "blahblah"
To get translations to show in templates:
Your
settings.pyshould have the following:You should have
'django.core.context_processors.i18n'in yourTEMPLATE_CONTEXT_PROCESSORSYou should add
'django.middleware.locale.LocaleMiddleware'in yourMIDDLEWARE_CLASSES(after'django.contrib.sessions.middleware.SessionMiddleware')Make sure your templates have
{% load i18n %}somewhere near the top.Once you have translated and compiled the messages, to actually get the translation to show, you need to tell django which language you need. To do that, do one of the following:
django_languagekey in the session which the language code you want.django_languageto the language you want.If after all the above, you are not getting any translations to show – then django is not able to find your message files.