views:

178

answers:

2

Hello - 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 language 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.

+2  A: 

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

Van Gale
You're right, I can now see the correct LANGUAGE_CODE in my template. However, the template still renders in English - how do I force it to render in the same language as LANGUAGE_CODE? I have all the translation files in place.
sa125
A: 

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

konryd