lang: add locale in django and login view

This commit is contained in:
AdrienLSH
2024-02-01 14:51:20 +01:00
parent 9cfdba794d
commit 52fbd30757
8 changed files with 63 additions and 22 deletions

View File

@ -20,6 +20,7 @@ import TournamentsView from "./views/tournament/TournamentsListView.js";
import TournamentCreateView from "./views/tournament/TournamentCreateView.js";
let client = new Client(location.origin);
let lang = client.lang;
let lastView = undefined;
let lastPageUrlBeforeLogin = undefined;
@ -144,13 +145,13 @@ document.addEventListener("DOMContentLoaded", async () => {
//Languages
Array.from(document.getElementById('languageSelector').children).forEach(el => {
el.onclick = async _ => {
if (await client.lang.changeLanguage(el.value))
if (await lang.changeLanguage(el.value))
return;
document.querySelector('#languageSelector > .active')?.classList.remove('active');
el.classList.add('active');
};
});
document.querySelector(`#languageSelector > [value=${client.lang.chosenLang}]`)
document.querySelector(`#languageSelector > [value=${lang.chosenLang}]`)
?.classList.add('active');
await client.isAuthentificate();
@ -158,4 +159,4 @@ document.addEventListener("DOMContentLoaded", async () => {
document.querySelector('a[href=\'' + location.pathname + '\']')?.classList.add('active');
});
export { client, navigateTo, reloadView }
export { client, lang, navigateTo, reloadView }