Translation support and minor login view changes #35

Open
rskthomas wants to merge 20 commits from feature/translation into main
2 changed files with 31 additions and 5 deletions
Showing only changes of commit 9db1f2dc9b - Show all commits

View file

@ -1,4 +1,4 @@
{% load i18n static %}
{% load i18n static language_code %}
<!doctype html>
<html lang="en">
@ -209,8 +209,23 @@
<!-- Footer -->
<footer class="footer text-center mt-auto py-3">
<div class="container">
<span class="text-muted">{{ commit_id }}</span>
<div class="container d-flex justify-content-center align-items-center">
<span class="text-muted mx-auto">{{ commit_id }}</span>
<div class="dropdown ms-auto">
<button class="btn btn-secondary dropdown-toggle" type="button" id="languageDropdown" data-bs-toggle="dropdown" aria-expanded="false">
{% get_current_language as LANGUAGE_CODE %}
{% get_language_info_list for LANGUAGES as languages %}
{{ LANGUAGE_CODE|get_language_code:languages }}
</button>
<ul class="dropdown-menu" aria-labelledby="languageDropdown">
{% for lang in languages %}
<li>
<a class="dropdown-item" href="{% url 'set_language' %}?language={{ lang.code }}">{{ lang.name_local }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</footer>

View file

@ -0,0 +1,11 @@
from django import template
from django.utils.translation import get_language_info
register = template.Library()
@register.filter
def get_language_code(language_code, languages):
for lang in languages:
if lang['code'] == language_code:
return lang['name_local'].lower()
return language_code.lower()