fix: SetLocale reads app_locale cookie first (partial from previous commit)
The SetLocale::resolve() edit was dropped from the previous commit. Cookie priority is essential for the switcher to actually take effect — without this the /locale route was setting a cookie that nothing read. Now resolve order: 1. app_locale cookie (persistent, survives session regen) 2. session locale 3. auth user.locale 4. tenant.settings.language 5. hard-coded 'ro' Suite: 306 unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,13 @@ class SetLocale
|
|||||||
|
|
||||||
private function resolve(Request $request): string
|
private function resolve(Request $request): string
|
||||||
{
|
{
|
||||||
|
// Cookie wins first — set explicit de utilizator via /locale/{lang},
|
||||||
|
// supraviețuiește regenerării sesiunii și subdomeniilor separate.
|
||||||
|
$cookie = $request->cookie('app_locale');
|
||||||
|
if ($cookie && in_array($cookie, self::SUPPORTED, true)) {
|
||||||
|
return $cookie;
|
||||||
|
}
|
||||||
|
|
||||||
// Session may not be started yet on early-stage middleware paths.
|
// Session may not be started yet on early-stage middleware paths.
|
||||||
if ($request->hasSession()) {
|
if ($request->hasSession()) {
|
||||||
$session = $request->session()->get('locale');
|
$session = $request->session()->get('locale');
|
||||||
|
|||||||
Reference in New Issue
Block a user