开发者

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:

  1. Make sure you have django.core.context_processors.i18n in settings.TEMPLATE_CONTEXT_PROCESSORS

  2. Make sure you pass RequestContext(request) as your context_instance if you are rendering your template using render_to_response


You might have left the USE_I18N = False in your settings. see docs

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜