Django 1.3 internationalization ... server switch required to switch languages?

I used django 1.2 before and had no problems switching languages ​​... In my template, I have this ...

<form action="/i18n/setlang/" method="post" class="forms"> {% csrf_token %} <input name="next" type="hidden" value="/next/page/" /> <select name="language" id="select_langauge" class="m_show hide"> {% for lang in LANGUAGES %} {% if lang.0 != '' %} <option value="{{lang.0}}">{{lang.1}}</option> {% endif %} {% endfor %} </select> 

This works fine with django 1.2. But since upgraded to Django 1.3, this will not work. I see that LANGUAGE_CODE is changing, but the actual language is not what I expected.

However, when I restart the django server, it shows the correct language. What am I missing ???

I have this in my settings.py

 LANGUAGE_CODE = 'en-us' SITE_ID = 1 USE_I18N = True gettext = lambda s: s LANGUAGES = ( ('', gettext('Please select')), ('en', gettext('English')), ('ko', gettext('Korean')), ) USE_L10N = True MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.locale.LocaleMiddleware', ) 
+4
source share
1 answer

I understood.

To dynamically change the language, the problem was fixed using ugettext_lazy (). (Before I used ugettext).

Link: https://docs.djangoproject.com/en/1.3/topics/i18n/internationalization/#lazy-translation

+1
source

All Articles