From f1b1f6e26676b6f2214c13d607839b8b48ab31c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Tue, 4 Nov 2025 15:40:53 -0300 Subject: [PATCH] Add locale management middleware: Introduced SetLocale middleware to handle language settings based on user session and available languages. Updated app bootstrap to include the middleware, ensuring proper localization support throughout the application. Enhanced language selector component for improved user experience. --- app/Http/Middleware/SetLocale.php | 52 +++++++++++++++++++ bootstrap/app.php | 4 +- .../custom/language-selector.blade.php | 6 +-- 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 app/Http/Middleware/SetLocale.php diff --git a/app/Http/Middleware/SetLocale.php b/app/Http/Middleware/SetLocale.php new file mode 100644 index 0000000..432bc9d --- /dev/null +++ b/app/Http/Middleware/SetLocale.php @@ -0,0 +1,52 @@ +withMiddleware(function (Middleware $middleware): void { - // + $middleware->web(append: [ + \App\Http\Middleware\SetLocale::class, + ]); }) ->withExceptions(function (Exceptions $exceptions): void { // diff --git a/resources/views/components/custom/language-selector.blade.php b/resources/views/components/custom/language-selector.blade.php index 4589a54..9ccf5ae 100644 --- a/resources/views/components/custom/language-selector.blade.php +++ b/resources/views/components/custom/language-selector.blade.php @@ -1,15 +1,13 @@ @php $languages = available_languages(); $currentLang = current_language_code(); + $currentLanguage = $languages->firstWhere('code', $currentLang); @endphp