Reputation: 1588
I have the following in my settings.py
LANGUAGE_CODE='es-US'
USE_I18N = True
and I also have django.middleware.locale.LocaleMiddleware in my MIDDLEWARE_CLASSES Tuple.
Is this configuration enough to see Base Django Error messages in Spanish or is there more to it?
Somehow my messages still keep showing in English.
Upvotes: 1
Views: 70
Reputation: 10553
To see the Django Base Error in Spanish, you need to set Spanish as your active language.
To make sure which is your active language you can add in your template:
{{request.session.django_language}}
{{request.LANGUAGE_CODE}}
and to see your active language in a view:
django.utils.translation.get_language()
I recomend you to have a sample view like next example to change between languages.
urls.py:
url(r'^set_language/(?P<language_code>[\w-]+)/?', 'yourapp.views.set_language', name='set_language'),
views.py
def set_language(request, language_code):
''' Change language '''
request.session['django_language'] = language_code
translation.activate(language_code)
return HttpResponseRedirect('/')
I also strongly recommend you to check this Django APP for translation:
There is also a tutorial to make the translation works, and this app makes very easy to translate the texts you mark for translation
Upvotes: 1