mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-13 23:56:47 +00:00
⚙️ Preserve user language preference in DomainMiddleware and adjust locale‑setting logic to avoid overwriting existing session values while still configuring domain‑specific app settings.
This commit is contained in:
@@ -49,16 +49,29 @@ class DomainMiddleware
|
|||||||
];
|
];
|
||||||
|
|
||||||
// App-Locale dynamisch setzen
|
// App-Locale dynamisch setzen
|
||||||
if (isset($domainArray[$domain]['locale'])) {
|
if (isset($domainArray[$domain])) {
|
||||||
session([
|
$domainConfig = $domainArray[$domain];
|
||||||
'lang_country' => $domainArray[$domain]['lang_country'],
|
|
||||||
'locale' => $domainArray[$domain]['locale'],
|
// Only set session values if they are not already set (first visit)
|
||||||
]);
|
// This allows user language preferences to persist
|
||||||
|
if (! session()->has('lang_country')) {
|
||||||
|
session(['lang_country' => $domainConfig['lang_country']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! session()->has('locale')) {
|
||||||
|
session(['locale' => $domainConfig['locale']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always set config values for the domain
|
||||||
config([
|
config([
|
||||||
'app.name' => $domainArray[$domain]['app_name'],
|
'app.name' => $domainConfig['app_name'],
|
||||||
'app.domain_country' => $domainArray[$domain]['locale'],
|
'app.domain_country' => $domainConfig['locale'],
|
||||||
]);
|
]);
|
||||||
App::setLocale($domainArray[$domain]['locale']);
|
|
||||||
|
// Set app locale based on user's current lang_country preference
|
||||||
|
$currentLangCountry = session('lang_country', $domainConfig['lang_country']);
|
||||||
|
$currentLocale = explode('-', $currentLangCountry)[0];
|
||||||
|
App::setLocale($currentLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|||||||
Reference in New Issue
Block a user