Translation support and minor login view changes #35
|
@ -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>
|
||||
|
||||
|
|
11
dashboard/templatetags/language_code.py
Normal file
11
dashboard/templatetags/language_code.py
Normal 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()
|
Loading…
Reference in a new issue