Skip to content
Snippets Groups Projects
Commit 01123c36 authored by Julian's avatar Julian
Browse files

Disabled German translations by default and fixed language selection in this case

parent 39794116
No related branches found
No related tags found
No related merge requests found
......@@ -129,10 +129,9 @@ def create_app(test_config=None): # pylint: disable=too-many-locals
@babel.localeselector
def get_locale(): #pylint: disable=unused-variable
language_cookie = request.cookies.get('language')
if language_cookie is not None:
if language_cookie is not None and language_cookie in app.config['LANGUAGES']:
return language_cookie
languages = list(map(lambda x: x.get('value'), app.config['LANGUAGES']))
return request.accept_languages.best_match(languages)
return request.accept_languages.best_match(list(app.config['LANGUAGES']))
app.add_template_global(get_locale)
......
......@@ -53,10 +53,11 @@ SESSION_COOKIE_SECURE=True
SESSION_COOKIE_HTTPONLY=True
SESSION_COOKIE_SAMESITE='Strict'
LANGUAGES=[
{ "value": "de", "display": "DE" },
{ "value": "en", "display": "EN" }
]
LANGUAGES={
# Language identifier (see Accept-Language HTTP header) -> Display Name
"en": "EN",
#"de": "DE", # Too incomplete right now to enable per default
}
ACL_ADMIN_GROUP="uffd_admin"
ACL_SELFSERVICE_GROUP="uffd_access"
......
......@@ -76,8 +76,8 @@
<form class="language-switch py-2 pr-1" method="POST" style="margin-left: -5px;" action="{{ url_for('setlang') }}">
<input type="hidden" name="ref" value="{{ request.url }}">
<select name="lang" class="bg-dark" style="border: 0px; color: rgba(255, 255, 255, 0.5);" onchange="$('.language-switch').submit()">
{% for language in config['LANGUAGES'] %}
<option value="{{ language['value'] }}" {{ 'selected' if language['value'] == get_locale() }}>{{ language['display'] }}</option>
{% for identifier, name in config['LANGUAGES'].items() %}
<option value="{{ identifier }}" {{ 'selected' if identifier == get_locale() }}>{{ name }}</option>
{% endfor %}
</select>
<noscript>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment