From a03561eaaf468b240e2d0f080a1887ac0e397cc9 Mon Sep 17 00:00:00 2001 From: Vasyka Date: Mon, 13 Jul 2026 20:25:25 +0000 Subject: [PATCH] fix: SetLocale reads app_locale cookie first (partial from previous commit) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- app/Http/Middleware/SetLocale.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Middleware/SetLocale.php b/app/Http/Middleware/SetLocale.php index d07fe12..6774c5c 100644 --- a/app/Http/Middleware/SetLocale.php +++ b/app/Http/Middleware/SetLocale.php @@ -25,6 +25,13 @@ class SetLocale 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. if ($request->hasSession()) { $session = $request->session()->get('locale');