Skip to content

Commit

Permalink
fix: SetLocale fallback redirect (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio authored Feb 22, 2024
1 parent acd6b41 commit 0a217a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/Http/Middleware/Front/SetLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public function handle(Request $request, Closure $next)
{
$locale = $request->segment(1);

// Set default locale as fallback
tap(settings('site.default_locale'), function ($locale) {
if (active_locales()->has($locale)) {
app()->setFallbackLocale($locale);
}
});

if (! active_locales()->has($locale)) {
return redirect()->to(
collect($request->segments())
Expand All @@ -30,13 +37,6 @@ public function handle(Request $request, Closure $next)

app()->setLocale($locale);

// Set default locale as fallback
tap(settings('site.default_locale'), function ($locale) {
if (active_locales()->has($locale)) {
app()->setFallbackLocale($locale);
}
});

return $next($request);
}
}

0 comments on commit 0a217a2

Please sign in to comment.