I can switch to ru and en, but when i try to switch to hy, nothing happens.
settings.py
...
LANGUAGE_CODE = 'en'
LANGUAGES = [
('en',_('English')),
('ru', _(u'Russian')),
('hy', _(u'Armenian')),
]
sidebar.html
...
<div id="sidebar-item-news">
<form action="/i18n/setlang/" method="post" id="language-select">
<input name="next" type="hidden" value="/" />
{% csrf_token %}
<select name="language">
{% for lang in LANGUAGES %}
<option value="{{ lang.0 }}">{{ lang.1 }}</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>
</div>
urls.py
# Internationalization
(r'^i18n/', include('django.conf.urls.i18n')),
After some debugging i figured out that request.session[‘django_language’] changes only to ru and en:
Current language is ru
[19/May/2012 22:51:55] "GET / HTTP/1.1" 200 13357
[19/May/2012 22:51:56] "POST /i18n/setlang/ HTTP/1.1" 302 0
Current language is ru
[19/May/2012 22:51:56] "GET / HTTP/1.1" 200 13357
I have all compiled translation files in /locale/hy and /locale/ru
If i put in home view translation.activate('hy') it works perfectly, but if i try to do this with my api
def api(request, type):
if request.method == 'POST':
if type == 'daytime':
request.session['daytime'] = request.POST['daytime']
return HttpResponse(request.session['daytime'])
if type == 'language':
request.session['custom_language'] = True
request.session['django_language'] = request.POST['language']
translation.activate(request.session['django_language'] )
return HttpResponse(request.session['django_language'])
raise Http404
else:
raise Http404
It fails as the i18n/setlang form.
How to fix this?
UPD
It seems that Django does not support armenian. (there is no ‘hy’ in /django/conf/locale/)
How should i work with this language?
See Locale restriction section in i18n docs. Looks like you need to modify Django a little.