This commit is contained in:
2025-11-25 00:53:25 +01:00
parent 804b7da7f0
commit f0153dda4a
5 changed files with 284 additions and 206 deletions

View File

@@ -2,14 +2,17 @@
document.addEventListener('DOMContentLoaded', function () {
const supportedLangs = ['de', 'en', 'it', 'fr'];
// Globale Config aus PHP-Partial (app_config.php)
const cfg = window.usbConfig || {};
const cfgLang = (cfg.lang || '').toLowerCase();
function resolveCurrentLang() {
const url = new URL(window.location.href);
const urlLang = (url.searchParams.get('lang') || '').toLowerCase();
const docLang = (document.documentElement.getAttribute('lang') || '').toLowerCase();
const globalLang = (window.currentLang || '').toLowerCase();
const url = new URL(window.location.href);
const urlLang = (url.searchParams.get('lang') || '').toLowerCase();
const docLang = (document.documentElement.getAttribute('lang') || '').toLowerCase();
if (supportedLangs.includes(urlLang)) return urlLang;
if (supportedLangs.includes(globalLang)) return globalLang;
if (supportedLangs.includes(cfgLang)) return cfgLang;
if (supportedLangs.includes(docLang)) return docLang;
return 'de';
}
@@ -27,7 +30,6 @@ document.addEventListener('DOMContentLoaded', function () {
const currentQuery = window.location.search || '';
const redirect = currentPath + currentQuery;
// Sprache aus URL / globalem State ableiten
const lang = resolveCurrentLang();
// Wenn wir bereits auf /login sind → nur zum #auth scrollen