I cannot get translations to show up for my templates. Here is what I have done:
trans tag where I want translations../manage.py makemessages -l es
./conf/locale/es/LC_MESSAGES/django.po
./manage.py compilemessages
LANGUAGE_CODE to 'es' in settings.pydjango.middleware.locale.LocaleMiddleware to MIDDLEWARE_CLASSES in between SessionMiddleware and CommonMiddleware.Only the english representations are still showing. What am I doing wrong here? Did I miss something?
Have you tried setting LOCALE_PATHS in your settings file? That fixed it for me...for more info check out an answer I wrote for a similar question or django's official documentation for the LOCALE_PATHS setting.
Django's LocaleMiddleware tries to determine the locale from the given request and replaces the LANGUAGE_CODE accordingly. It goes through the following steps:
django_language. Set the language to the given locale in this session. If not existing it goes to 2.HTTP_ACCEPT_LANGUAGE header. If not possible it will go to 4.LANGUAGE_CODE setting as given locale.In all steps except 4 it will check if the language is given in your LANGUAGES setting, which is a tuple of 2-tuples representing language code and language title. Make sure you set/overwrite the default, since the default would be a tuple of all available Django languages.
If you have multiple languages in your Django site:
Make sure your session or cookies are set correctly. You could use Django's internal view for setting the language (django.views.i18n.set_language).
If you got only one language:
If you only have Spanish you usually don't need to bother with this. Just make sure LANGUAGES and LANGUAGE_CODE is set. It will not attempt to set the pages language to your browsers language if it is not provided in LANGUAGES. Additionally you should make sure that USE_I18N = True. That should be the default though, so make at least sure you didn't set it to False somewhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With