add language selector, use set_language redirect view from django

This commit is contained in:
Thomas Waldmann 2014-08-25 00:01:26 +02:00
parent e38e0bda55
commit b1afe75a62
2 changed files with 22 additions and 0 deletions

View File

@ -76,6 +76,27 @@
</li>
{% endif %}
</ul>
<ul class="nav navbar-nav pull-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-language fa-fw"></i> {{ LANGUAGE_CODE }} <b class="caret"></b></a>
<ul class="dropdown-menu">
{% get_language_info_list for LANGUAGES as langs %}
{% for lang in langs %}
{% if lang.code != LANGUAGE_CODE %}
<li>
<form name="setLang{{ lang.name }}" action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<input type="hidden" name="language" value="{{ lang.code }}" />
<a href="#" onclick="document.setLang{{ lang.name }}.submit();return false;">
{{ lang.name_local }} ({{ lang.name }}) [{{ lang.code }}]
</a>
</form>
</li>
{% endif %}
{% endfor %}
</ul>
</li>
</ul>
</div>
</div>
</div>

View File

@ -32,6 +32,7 @@ urlpatterns = patterns(
# registration and user settings
url(r'^account/', include('nsupdate.accounts.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^', include('nsupdate.main.urls')),
)