Reputation: 615
Hello i have next situation:
In settings.py:
LANGUAGE_CODE = 'ru-ru'
LOCALE_PATHS = (
os.path.join(BASE_DIR, "locale"),
)
LANGUAGES = [
('en', 'English'),
('ru', 'Russian'),
]
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
In urls.py i have:
url(r'^i18n/', include('django.conf.urls.i18n')),
#url(r'^jsi18n/$', javascript_catalog, js_info_dict, name='javascript-catalog'),
url(r'^admin_tools/', include('admin_tools.urls')),
Language change form:
<form id="lang-bar" action="{% url 'set_language' %}" method="post">{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
<input class="button" type="submit" value="{% trans 'Change' %}" />
</form>
I have created locale and translated and compile it, but when i click change the language isn't change. It other project where LANGUAGE_CODE = 'en-us'
this code work great
Upvotes: 1
Views: 971
Reputation: 615
Sorry my bad forgot to add 'django.middleware.locale.LocaleMiddleware',
to MIDDLEWARE
in settings.py
Upvotes: 1