Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Correctly set language in template

Roland Geider2d7decff129f
diff --git a/wger/core/templates/template.html b/wger/core/templates/template.html
index bd59e86b0..a5293f338 100644
--- a/wger/core/templates/template.html
+++ b/wger/core/templates/template.html
@@ -23,6 +23,7 @@
<html lang="{{ language.short_name }}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <meta http-equiv="content-language" content="{{ i18n_language.code }}">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author" content="Roland Geider">
@@ -131,7 +132,7 @@
</div>
</div>
<div id="current-url" data-current-url="{{ request_full_path }}"></div>
- <div id="current-language" data-current-language="{{ language.short_name }}"></div>
+ <div id="current-language" data-current-language="{{ i18n_language.code }}"></div>
{# #}
diff --git a/wger/core/templates/template_features.html b/wger/core/templates/template_features.html
index ba5b0d8af..17342a210 100644
--- a/wger/core/templates/template_features.html
+++ b/wger/core/templates/template_features.html
@@ -18,9 +18,9 @@
{% load i18n static compress wger_extras %}
-<html lang="{{language.short_name}}">
+<html lang="{{ language.short_name }}">
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8">
<meta name="author" content="Roland Geider">
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -37,25 +37,28 @@
<!-- twitter cards -->
{% block twittercard %}
- {% if twitter %}
- <meta content="summary" name="twitter:card">
- <meta content="@{{ twitter }}" name="twitter:site">
- {% endif %}
+ {% if twitter %}
+ <meta content="summary" name="twitter:card">
+ <meta content="@{{ twitter }}" name="twitter:site">
+ {% endif %}
{% endblock %}
{% compress css %}
- <link rel="stylesheet" type="text/css" href="{% static 'yarn/bootstrap/dist/css/bootstrap.min.css' %}">
- <link rel="stylesheet" type="text/css" href="{% static 'yarn/components-font-awesome/css/all.css' %}">
- <link rel="stylesheet" type="text/css" href="{% static 'css/agency.css' %}">
- <link rel="stylesheet" type="text/css" href="{% static 'yarn/shariff/dist/shariff.min.css' %}">
+ <link rel="stylesheet" type="text/css"
+ href="{% static 'yarn/bootstrap/dist/css/bootstrap.min.css' %}">
+ <link rel="stylesheet" type="text/css"
+ href="{% static 'yarn/components-font-awesome/css/all.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/agency.css' %}">
+ <link rel="stylesheet" type="text/css"
+ href="{% static 'yarn/shariff/dist/shariff.min.css' %}">
{% endcompress %}
<link rel="icon" href="{% static 'images/favicon.png' %}" type="image/png">
{% compress js %}
- <script src="{% static 'yarn/jquery/dist/jquery.js' %}"></script>
- <script src="{% static 'yarn/bootstrap/dist/js/bootstrap.min.js' %}"></script>
+ <script src="{% static 'yarn/jquery/dist/jquery.js' %}"></script>
+ <script src="{% static 'yarn/bootstrap/dist/js/bootstrap.min.js' %}"></script>
{% endcompress %}
<title>wger Workout Manager - {% translate "Features" %}</title>
@@ -64,13 +67,12 @@
<body id="page-top" class="index">
{% if user.is_authenticated %}
-{% include 'navigation.html' %}
-{% endif %}
-
- {% block template %}{% endblock %}
- <div id="current-url" data-current-url="{{request_full_path}}"></div>
- <div id="current-language" data-current-language="{{language.short_name}}"></div>
+ {% include 'navigation.html' %}
+{% endif %}
+{% block template %}{% endblock %}
+<div id="current-url" data-current-url="{{ request_full_path }}"></div>
+<div id="current-language" data-current-language="{{ i18n_language.code }}"></div>
<footer class="bg-darkest-gray">
@@ -79,7 +81,8 @@
<div class="col-md-4">
<ul class="list-inline quicklinks">
<li class="list-inline-item">
- <a href="{% url 'software:about-us' %}" class="text-muted small">{% translate "About us" %}</a>
+ <a href="{% url 'software:about-us' %}"
+ class="text-muted small">{% translate "About us" %}</a>
</li>
</ul>
</div>
@@ -96,7 +99,8 @@
</a>
</li>
<li class="list-inline-item">
- <a href="https://hosted.weblate.org/engage/wger/" title="{% translate 'Translate' %}">
+ <a href="https://hosted.weblate.org/engage/wger/"
+ title="{% translate 'Translate' %}">
<span class="{% fa_class 'globe' %}"></span>
</a>
</li>
@@ -107,18 +111,20 @@
<span class="{% fa_class 'share-alt' %}"></span>
</a>
<div class="clearfix"></div>
- {% endif %}
+ {% endif %}
</li>
</ul>
</div>
<div class="col-md-4 text-lg-right">
<ul class="list-inline quicklinks">
<li class="list-inline-item">
- <a href="{% url 'core:imprint' %}" class="text-muted small">{% translate "Imprint" %}</a>
+ <a href="{% url 'core:imprint' %}"
+ class="text-muted small">{% translate "Imprint" %}</a>
</li>
<li class="list-inline-item">
- <a href="{% url 'software:tos' %}" class="text-muted small">{% translate "Terms of service" %}</a>
+ <a href="{% url 'software:tos' %}"
+ class="text-muted small">{% translate "Terms of service" %}</a>
</li>
</ul>
</div>
diff --git a/wger/utils/language.py b/wger/utils/language.py
index d2e435c6c..553561129 100644
--- a/wger/utils/language.py
+++ b/wger/utils/language.py
@@ -52,4 +52,8 @@ def load_language(language_code=None):
def get_language_data(language):
- return {'name': language[1], 'path': f'images/icons/flags/{language[0]}.svg'}
+ return {
+ 'name': language[1],
+ 'code': language[0],
+ 'path': f'images/icons/flags/{language[0]}.svg'
+ }