viewing translations in django templates (e.g - making it work)
I'm trying to figure out the django translation system, so I wrote a little test app. I created the translation files and compiled them (*.po and *.mo), and now I'm trying to render a template in a different language. I change the LANGUAGE_CODE in my settings.py to the other language code, but the template still renders in English. No errors are given, just can't see the other langua开发者_如何学Pythonge I'm trying out, even though I translated, compiled and all that. I have the db set up to support whatever's required. I also used the get_current_language in the template:
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_current_language_bidi as LANGUAGE_BIDI %}
the current language is {{ LANGUAGE_CODE }}
but I'm getting blank where the code should appear. What am I missing? thanks.
This is probably one of two problems:
Make sure you have
django.core.context_processors.i18n
insettings.TEMPLATE_CONTEXT_PROCESSORS
Make sure you pass
RequestContext(request)
as yourcontext_instance
if you are rendering your template usingrender_to_response
You might have left the USE_I18N = False
in your settings. see docs
精彩评论