header language

This commit is contained in:
2025-11-26 00:55:21 +01:00
parent 9a2ba6dd8a
commit 354bf34aa8

View File

@@ -46,36 +46,28 @@ if ($isLoggedIn) {
} }
// ----------------------------------------- // -----------------------------------------
// Dynamische Sprachliste // Sprachkontext direkt aus fileload.php
// kommt aus app_config.php:
//
// $usbConfig['i18n']['available'] = [
// 'de' => ['code'=>'de','label'=>'Deutsch','flag'=>'🇩🇪'],
// ...
// ];
// $usbConfig['i18n']['current'] = 'de';
// ----------------------------------------- // -----------------------------------------
// aktuelle Sprache aus globalem Kontext // Aktuelle Sprache und verfügbare Sprachen aus den GLOBALS
$currentLang = $usbConfig['i18n']['current'] ?? ($lang ?? 'en'); $currentLang = $GLOBALS['lang'] ?? 'en';
$availableLangs = $GLOBALS['availableLangs'] ?? [];
// verfügbare Sprachen aus Config // Sicherheits-Fallback: falls aus irgendeinem Grund leer
$availableLangs = $usbConfig['i18n']['available'] ?? []; if (!is_array($availableLangs) || empty($availableLangs)) {
// Fallback: Wenn Config noch nichts liefert, nimm nur die aktuelle Sprache
if (!$availableLangs || !is_array($availableLangs)) {
$availableLangs = [ $availableLangs = [
$currentLang => [ $currentLang => [
'code' => $currentLang, 'code' => $currentLang,
'label' => strtoupper($currentLang), 'label' => strtoupper($currentLang),
'flag' => '🏳️' 'flag' => '🏳️',
] ],
]; ];
} }
// Sicherstellen, dass currentLang in der Liste ist // Sicherstellen, dass currentLang eine gültige Sprache ist
if (!isset($availableLangs[$currentLang])) { if (!isset($availableLangs[$currentLang])) {
$currentLang = array_key_first($availableLangs); $keys = array_keys($availableLangs);
$currentLang = $keys[0] ?? 'en';
} }
// aktuelle Sprache-Info // aktuelle Sprache-Info
@@ -83,6 +75,7 @@ $currentLangInfo = $availableLangs[$currentLang] ?? ['code' => $currentLang];
$currentLangFlag = $currentLangInfo['flag'] ?? '🏳️'; $currentLangFlag = $currentLangInfo['flag'] ?? '🏳️';
$currentLangCode = strtoupper($currentLangInfo['code'] ?? $currentLang); $currentLangCode = strtoupper($currentLangInfo['code'] ?? $currentLang);
$currentLangLabel = $currentLangInfo['label'] ?? $currentLangCode; $currentLangLabel = $currentLangInfo['label'] ?? $currentLangCode;
?> ?>
<header class="sticky top-0 z-40 border-b border-brand-border/70 backdrop-blur bg-brand-bg/85"> <header class="sticky top-0 z-40 border-b border-brand-border/70 backdrop-blur bg-brand-bg/85">
<div class="mx-auto max-w-6xl px-4 sm:px-6 lg:px-8 flex items-center justify-between h-16"> <div class="mx-auto max-w-6xl px-4 sm:px-6 lg:px-8 flex items-center justify-between h-16">