0
Ich kann die Sprache in der Vorlage nicht ändern. In firebug ich sehe, dassDjango übersetzen
<html lang="en">
wheh i auf Ukraine klicken, Sprache chang auf <html lang="uk">
aber in der Template-Sprache nicht geändert. Wie kann ich das beheben?
mein urls.py
from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt
from django.views.i18n import set_language
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^registration/$', views.registration, name='registration'),
url(r'^logout/$', views.logout_view, name='logout'),
url(r'^login/$', views.login_view, name='login'),
url(r'^i18n/setlang/$', csrf_exempt(set_language), name='set_language'),
]
mein index.html
form action="{% url 'set_language' %}" method="POST">
{% csrf_token %}
<input name="next" type="hidden" value="{{ request.get_full_path|slice:'3:' }}" />
<ul class="nav navbar-nav navbar-right language menu">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<li>
<button type="submit"
name="language"
value="{{ language.code }}"
class="{% if language.code == LANGUAGE_CODE %}selected{% endif %}">
{{ language.name_local }}
</button>
</li>
{% endfor %}
</ul>
</form>