choose language

This commit is contained in:
Laura Klünder 2017-12-10 16:22:26 +01:00
parent 2656b6e050
commit 302bf909a6
4 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,25 @@
{% extends 'site/base.html' %}
{% load i18n %}
{% block content %}
<main class="account">
<div class="narrow">
<h2>{% trans 'Pick your language' %}</h2>
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="{% url 'site.index' %}" />
{% get_current_language as CURRENT_LANGUAGE %}
{% get_available_languages as LANGUAGES %}
<select name="language">
{% for language, title in LANGUAGES %}
<option value="{{ language }}"{% if language == CURRENT_LANGUAGE %} selected="selected"{% endif %}>
{{ language | language_name_local }}
</option>
{% endfor %}
</select>
<button type="submit">{% trans 'Set language' %}</button>
</form>
</div>
</main>
{% endblock %}

View file

@ -6,6 +6,8 @@
{% block content %}
<main class="map" data-state="{{ state }}"{% if embed %} data-embed{% endif %}>
<section id="attributions">
{% get_current_language as CURRENT_LANGUAGE %}
<a href="{% url 'site.language' %}" id="choose-language">{{ CURRENT_LANGUAGE | language_name_local }}</a>
<a href="{% url 'editor.index' %}" target="_blank">{% trans 'Editor' %}</a> //
<a href="/api/" target="_blank">{% trans 'API' %}</a> //
<a href="https://github.com/c3nav/c3nav/" rel="external" target="_blank">{% trans 'GitHub' %}</a>

View file

@ -1,7 +1,7 @@
from django.conf.urls import url
from c3nav.site.views import (access_redeem_view, account_view, change_password_view, login_view, logout_view,
map_index, qr_code, register_view)
from c3nav.site.views import (access_redeem_view, account_view, change_password_view, choose_language, login_view,
logout_view, map_index, qr_code, register_view)
slug = r'(?P<slug>[a-z0-9-_.:]+)'
slug2 = r'(?P<slug2>[a-z0-9-_.:]+)'
@ -22,4 +22,5 @@ urlpatterns = [
url(r'^account/$', account_view, name='site.account'),
url(r'^account/change_password$', change_password_view, name='site.account.change_password'),
url(r'^access/(?P<token>[^/]+)$', access_redeem_view, name='site.access.redeem'),
url(r'^lang/$', choose_language, name='site.language'),
]

View file

@ -274,3 +274,7 @@ def access_redeem_view(request, token):
num_restrictions),
', '.join(str(restriction.title) for restriction in token.restrictions)),
})
def choose_language(request):
return render(request, 'site/language.html', {})