From db138479aa2d861951ec6e64e0e5e4b3ce29aaea Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 19 Dec 2023 17:43:22 +0000 Subject: [PATCH] Updated locale middleware for mapping Signed-off-by: snipe --- app/Http/Middleware/CheckLocale.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/Http/Middleware/CheckLocale.php b/app/Http/Middleware/CheckLocale.php index 75cba13261..ea66c59efa 100644 --- a/app/Http/Middleware/CheckLocale.php +++ b/app/Http/Middleware/CheckLocale.php @@ -4,6 +4,7 @@ namespace App\Http\Middleware; use App\Models\Setting; use Closure; +use \App\Helpers\Helper; class CheckLocale { @@ -18,22 +19,24 @@ class CheckLocale */ public function handle($request, Closure $next, $guard = null) { + + // Default app settings from config + $language = config('app.locale'); + if ($settings = Setting::getSettings()) { + // User's preference if (($request->user()) && ($request->user()->locale)) { - \App::setLocale($request->user()->locale); + $language = $request->user()->locale; // App setting preference } elseif ($settings->locale != '') { - \App::setLocale($settings->locale); - - // Default app setting - } else { - \App::setLocale(config('app.locale')); + $language = $settings->locale; } - } - \App::setLocale(config('app.locale')); + } + + \App::setLocale(Helper::mapLegacyLocale($language)); return $next($request); } }