diff --git a/config/fileload.php b/config/fileload.php index ed4c10b..480ae21 100644 --- a/config/fileload.php +++ b/config/fileload.php @@ -115,17 +115,21 @@ if (empty($availableLangs)) { } // Falls Sprache ungültig oder nicht in available: -// 1) Wenn 'en' existiert → nimm 'en' -// 2) Sonst: erste verfügbare Sprache +// 1) Wenn 'de' existiert → nimm 'de' +// 2) sonst, wenn 'en' existiert → nimm 'en' +// 3) sonst: erste verfügbare Sprache if (!$lang || !isset($availableLangs[$lang])) { if (isset($availableLangs['de'])) { $lang = 'de'; + } elseif (isset($availableLangs['en'])) { + $lang = 'en'; } else { $keys = array_keys($availableLangs); - $lang = $keys[0] ?? 'de'; + $lang = $keys[0] ?? 'en'; } } + // ----------------------------------------------------------- // 3) Aktive Sprachdatei laden // ----------------------------------------------------------- @@ -163,6 +167,7 @@ $GLOBALS['i18n'] = [ 'fallback' => $fallbackLangData, ]; +$lang = $GLOBALS['lang'] ?? 'de'; // ----------------------------------------------------------- // 6) Rest des Systems laden // ----------------------------------------------------------- diff --git a/partials/structure/header.php b/partials/structure/header.php index 90ed1ac..2374773 100644 --- a/partials/structure/header.php +++ b/partials/structure/header.php @@ -77,7 +77,7 @@ $currentLangLabel = $currentLangInfo['label'] ?? $currentLangCode; // ----------------------------------------- // Helper: URL mit anderem ?lang=.. bauen // ----------------------------------------- -$currentPath = strtok($_SERVER['REQUEST_URI'] ?? '/', '?'); +$currentPath = strtok($_SERVER['REQUEST_URI'] ?? '/', '?'); $currentQuery = $_GET ?? []; function build_lang_url(string $code, string $path, array $query): string @@ -137,13 +137,17 @@ function build_lang_url(string $code, string $path, array $query): string class="hidden absolute right-0 mt-2 w-32 rounded-xl bg-brand-surface border border-brand-border shadow-lg py-1 text-xs z-40"> $info): ?> + class="lang-pill flex items-center gap-2 w-full text-left px-3 py-1.5 uppercase tracking-[0.18em] text-brand-muted hover:text-brand-primary hover:bg-brand-bg/60"> diff --git a/public/index.php b/public/index.php index 5199e7d..e552b39 100644 --- a/public/index.php +++ b/public/index.php @@ -3,10 +3,6 @@ $pageKey = 'landing'; require_once dirname(__DIR__) . '/config/fileload.php'; -// Sprachlogik: -$lang = $_GET['lang'] ?? 'en'; -$lang = in_array($lang, ['de','en','it','fr']) ? $lang : 'en'; - // User-Dummy (später über Login ersetzen) $userInitials = null; diff --git a/public/landingpage/dashboard/index.php b/public/landingpage/dashboard/index.php index 1e2b08e..0c9e0be 100644 --- a/public/landingpage/dashboard/index.php +++ b/public/landingpage/dashboard/index.php @@ -4,9 +4,6 @@ $pageKey = 'dashboard'; require_once dirname(__DIR__) . '/config/fileload.php'; -// Sprachlogik -$lang = $_GET['lang'] ?? 'de'; -$lang = in_array($lang, ['de','en','it','fr'], true) ? $lang : 'de'; // User aus Session holen $currentUser = $_SESSION['user'] ?? null; diff --git a/public/landingpage/fakecheck/index.php b/public/landingpage/fakecheck/index.php index 8141289..8f5d0cf 100644 --- a/public/landingpage/fakecheck/index.php +++ b/public/landingpage/fakecheck/index.php @@ -5,9 +5,6 @@ require_once dirname(__DIR__) . '/config/fileload.php'; // public/fakecheck/index.php -// Sprachlogik wie auf der Startseite -$lang = $_GET['lang'] ?? 'en'; -$lang = in_array($lang, ['de','en','it','fr']) ? $lang : 'en'; // User-Dummy (später über Login ersetzen) $userInitials = null; diff --git a/public/landingpage/login/index.php b/public/landingpage/login/index.php index c3e2326..a38eb4c 100644 --- a/public/landingpage/login/index.php +++ b/public/landingpage/login/index.php @@ -3,9 +3,6 @@ $pageKey = 'login'; require_once __DIR__ . '/../../../config/fileload.php'; tpl_add_script('/assets/js/auth.js', 'footer', true, false, '', 'auth-1'); -// Sprachlogik: -$lang = $_GET['lang'] ?? 'en'; -$lang = in_array($lang, ['de','en','it','fr']) ? $lang : 'en'; // später: echte Session $userInitials = null;