Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Correctly translate the path in the language switcher

Roland Geider767d30b864b8
diff --git a/manager/context_processor.py b/manager/context_processor.py
index 523b77978..eea6c64b8 100644
--- a/manager/context_processor.py
+++ b/manager/context_processor.py
@@ -23,6 +23,8 @@ from workout_manager import constants
def processor(request):
+ full_path = request.get_full_path()
+
context = {
# Application version
'version': get_version(),
@@ -34,7 +36,11 @@ def processor(request):
'language': load_language(),
# The current path
- 'request_full_path': request.get_full_path()
+ 'request_full_path': full_path,
+
+ # Translation links
+ 'i18n_path': {'de': '/de' + full_path[3:],
+ 'en': '/en' + full_path[3:]},
}
# Pseudo-intelligent navigation here
diff --git a/manager/templates/template.html b/manager/templates/template.html
index 9f71953fa..44c3b9141 100644
--- a/manager/templates/template.html
+++ b/manager/templates/template.html
@@ -170,7 +170,7 @@
{% endif %}
<li {% if language.short_name == 'de' %}class="active"{% endif %}>
- <a href="/de/">
+ <a href="{{i18n_path.de}}">
<img src="{% static 'images/icons/flag-de.svg' %}"
width="18"
height="18"
@@ -179,7 +179,7 @@
{% trans "German" %}</a>
</li>
<li {% if language.short_name == 'en' %}class="active"{% endif %}>
- <a href="/en/">
+ <a href="{{i18n_path.en}}">
<img src="{% static 'images/icons/flag-en.svg' %}"
width="18"
height="18"