我无法在模板中更改语言。在萤火虫中,我看到了
<html lang="en">
我点击乌克兰,<html lang="uk">
但是,在模板语言中没有改变。我怎么能解决这个问题?
我的 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'),
]
我的 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>
答案 0 :(得分:0)
我的错误是不断的名字,我有这个
LOCAL_PATH = (
'home/name/myapp/locale'
)
我改变了这个LOCALE_PATH S ,一切正常。