[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-bank] 02/02: implement language switch
From: |
gnunet |
Subject: |
[taler-bank] 02/02: implement language switch |
Date: |
Wed, 03 Feb 2021 11:17:39 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository bank.
commit 7d64c07a7a5939ace427c1d503268056f6c861be
Author: MS <ms@taler.net>
AuthorDate: Wed Feb 3 11:17:22 2021 +0100
implement language switch
---
talerbank/app/templates/base.html | 20 ++++++++++++++++++++
talerbank/jinja2.py | 9 +++++++++
2 files changed, 29 insertions(+)
diff --git a/talerbank/app/templates/base.html
b/talerbank/app/templates/base.html
index 249986e..148097a 100644
--- a/talerbank/app/templates/base.html
+++ b/talerbank/app/templates/base.html
@@ -82,6 +82,26 @@
<a href="{{ env('TALER_ENV_URL_MERCHANT_BLOG', '#') }}">{{ _("Essay
Shop") }}</a>
<a href="{{ env('TALER_ENV_URL_MERCHANT_DONATIONS', '#') }}">{{
_("Donations") }}</a>
<a href="{{ env('TALER_ENV_URL_MERCHANT_SURVEY', '#') }}">{{
_("Tipping/Survey") }}</a>
+ <span class="right">
+ {% set lang = get_locale(request.path) %}
+ {{ {"en": _("English [en]"), "es": _("Spanish [es]"), "de": _("German
[de]"), "sv": _("Swedish [sv]")}[lang] | default("en") }}
+ <div class="nav">
+ <br>
+ {% if lang != 'en' %}
+ <a href="/en/" class="navbtn">English [en]</a><br>
+ {% endif %}
+ {% if lang != 'de' %}
+ <a href="/de/" class="navbtn">Deutsch [de]</a><br>
+ {% endif %}
+ {% if lang != 'es' %}
+ <a href="/es/" class="navbtn">EspaƱol [es]</a><br>
+ {% endif %}
+ {% if lang != 'sv' %}
+ <a href="/sv/" class="navbtn">Svenska [sv]</a><br>
+ {% endif %}
+
+ </div>
+ </span>
</nav>
</div>
<section id="main" class="content">
diff --git a/talerbank/jinja2.py b/talerbank/jinja2.py
index 9b8d59b..b26b984 100644
--- a/talerbank/jinja2.py
+++ b/talerbank/jinja2.py
@@ -128,6 +128,13 @@ def tojson(x):
def amount_stringify(amount):
return amount.stringify(settings.TALER_DIGITS, pretty=True)
+def get_locale(url):
+ parts = url.split('/', 2)
+ if (2 >= len(parts)):
+ # Totally unexpected path format, do not localize
+ return "en"
+ lang = parts[1]
+ return lang
def environment(**options):
env = Environment(**options)
@@ -141,6 +148,8 @@ def environment(**options):
"amount_stringify": amount_stringify,
"tojson": tojson,
"_": gettext,
+ "get_locale": get_locale
+
}
)
return env
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.