Add language switch functionality: Implemented a new route for switching languages, allowing users to change the application language dynamically. Introduced a language selector component in the navbar for improved user experience, ensuring proper localization support. Updated the switch_language helper function to streamline locale management.

This commit is contained in:
Ümit Tunç
2025-11-04 15:28:24 -03:00
parent 7da35f79bb
commit 45534be05e
3 changed files with 51 additions and 4 deletions
+14
View File
@@ -54,6 +54,20 @@ Route::get('/debug-homepage', function () {
]);
});
// Language Switch
Route::get('/lang/{locale}', function ($locale) {
if (function_exists('switch_language')) {
switch_language($locale);
} else {
$language = \App\Models\Language::findByCode($locale);
if ($language && $language->is_active) {
app()->setLocale($locale);
session(['locale' => $locale]);
}
}
return redirect()->back();
})->name('language.switch');
// Homepage -> admin panelinde "is_homepage" olarak işaretli sayfa dinamik olarak gösterilir
Route::get('/', [PageController::class, 'index'])->name('homepage');