Début de la traduction
This commit is contained in:
parent
ee6be9983e
commit
7ab3321982
5 changed files with 80 additions and 5 deletions
|
@ -6,6 +6,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Secrets
|
# Secrets
|
||||||
|
@ -59,6 +60,7 @@ INSTALLED_APPS = [
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"django.middleware.security.SecurityMiddleware",
|
||||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
|
"django.middleware.locale.LocaleMiddleware",
|
||||||
"django.middleware.common.CommonMiddleware",
|
"django.middleware.common.CommonMiddleware",
|
||||||
"django.middleware.csrf.CsrfViewMiddleware",
|
"django.middleware.csrf.CsrfViewMiddleware",
|
||||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||||
|
@ -132,6 +134,13 @@ USE_I18N = True
|
||||||
USE_L10N = True
|
USE_L10N = True
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
LANGUAGES = [
|
||||||
|
("fr", _("Français")),
|
||||||
|
("en", _("Anglais")),
|
||||||
|
]
|
||||||
|
|
||||||
|
LOCALE_PATHS = [os.path.join(BASE_DIR, "shared", "locale")]
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Paramètres des fichiers statiques
|
# Paramètres des fichiers statiques
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
|
@ -10,6 +10,7 @@ urlpatterns = [
|
||||||
path("elections/", include("elections.urls")),
|
path("elections/", include("elections.urls")),
|
||||||
path("auth/", include("shared.auth.urls")),
|
path("auth/", include("shared.auth.urls")),
|
||||||
path("authens/", include("authens.urls")),
|
path("authens/", include("authens.urls")),
|
||||||
|
path("i18n/", include("django.conf.urls.i18n")),
|
||||||
]
|
]
|
||||||
|
|
||||||
if "debug_toolbar" in settings.INSTALLED_APPS:
|
if "debug_toolbar" in settings.INSTALLED_APPS:
|
||||||
|
|
7
shared/static/images/en.svg
Normal file
7
shared/static/images/en.svg
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-gb" viewBox="0 0 640 480">
|
||||||
|
<path fill="#012169" d="M0 0h640v480H0z"/>
|
||||||
|
<path fill="#FFF" d="M75 0l244 181L562 0h78v62L400 241l240 178v61h-80L320 301 81 480H0v-60l239-178L0 64V0h75z"/>
|
||||||
|
<path fill="#C8102E" d="M424 281l216 159v40L369 281h55zm-184 20l6 35L54 480H0l240-179zM640 0v3L391 191l2-44L590 0h50zM0 0l239 176h-60L0 42V0z"/>
|
||||||
|
<path fill="#FFF" d="M241 0v480h160V0H241zM0 160v160h640V160H0z"/>
|
||||||
|
<path fill="#C8102E" d="M0 193v96h640v-96H0zM273 0v480h96V0h-96z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 538 B |
7
shared/static/images/fr.svg
Normal file
7
shared/static/images/fr.svg
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-fr" viewBox="0 0 640 480">
|
||||||
|
<g fill-rule="evenodd" stroke-width="1pt">
|
||||||
|
<path fill="#fff" d="M0 0h640v480H0z"/>
|
||||||
|
<path fill="#00267f" d="M0 0h213.3v480H0z"/>
|
||||||
|
<path fill="#f31830" d="M426.7 0H640v480H426.7z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 292 B |
|
@ -82,6 +82,16 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Language selection
|
||||||
|
var $langs = document.querySelectorAll('.dropdown-item.lang-selector') || [];
|
||||||
|
|
||||||
|
$langs.forEach($lang => {
|
||||||
|
$lang.addEventListener('click', () => {
|
||||||
|
document.getElementById('lang-input').value = $lang.dataset.lang;
|
||||||
|
document.getElementById('lang-form').submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -105,8 +115,47 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block auth %}
|
|
||||||
<div class="level-right px-5">
|
<div class="level-right px-5">
|
||||||
|
{# Choix de la langue #}
|
||||||
|
<div class="level-item pr-3">
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
{% get_available_languages as LANGUAGES %}
|
||||||
|
{% get_language_info_list for LANGUAGES as langs %}
|
||||||
|
|
||||||
|
<form action="{% url "set_language" %}" method="POST" id="lang-form">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="language" id="lang-input">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="dropdown">
|
||||||
|
<div class="dropdown-trigger">
|
||||||
|
<a class="tag is-large is-primary is-light" aria-haspopup="true" aria-controls="dropdown-menu">
|
||||||
|
<span class="icon has-text-primary">
|
||||||
|
<i class="fas fa-language"></i>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<div class="dropdown-content">
|
||||||
|
{% for lang in langs %}
|
||||||
|
{% with lang_svg="images/"|add:lang.code|add:".svg" %}
|
||||||
|
<a class="dropdown-item lang-selector" data-lang="{{ lang.code }}">
|
||||||
|
<span class="icon-text">
|
||||||
|
<span class="icon">
|
||||||
|
<img src="{% static lang_svg %}">
|
||||||
|
</span>
|
||||||
|
<span class="ml-1">{{ lang.name_translated }}</span>
|
||||||
|
</span>
|
||||||
|
{% endwith %}
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% block auth %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<div class="level is-mobile">
|
<div class="level is-mobile">
|
||||||
<div class="level-item mr-5">
|
<div class="level-item mr-5">
|
||||||
|
@ -125,15 +174,17 @@
|
||||||
|
|
||||||
<div class="level-item py-2">
|
<div class="level-item py-2">
|
||||||
<a class="tag has-text-primary is-size-5" href="{% url 'authens:login' %}?next={{ request.path }}">
|
<a class="tag has-text-primary is-size-5" href="{% url 'authens:login' %}?next={{ request.path }}">
|
||||||
<span>{% trans "Se connecter" %}</span>
|
<span class="icon-text">
|
||||||
<span class="icon">
|
<span>{% trans "Se connecter" %}</span>
|
||||||
<i class="fas fa-sign-in-alt"></i>
|
<span class="icon">
|
||||||
|
<i class="fas fa-sign-in-alt"></i>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
|
||||||
</nav>
|
</nav>
|
||||||
{% block layout %}
|
{% block layout %}
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
|
|
Loading…
Reference in a new issue