localization with laravel jetstream/ fortify when I want to use localization in route with jetstream/fortify I faced 404 not found when I click each button on the profile page ( save , enable , delete account ) I don't know how to fixed ?
@vincent15000
RouteServiceProvider .
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
$locale = request()->segment(1);
Route::middleware('web')
->prefix($locale)
->group(base_path('routes/web.php'));
});
}
Middleware SetLanguage
public function handle(Request $request, Closure $next)
{
$locale = $request->segment(1);
if (!in_array($locale, config('app.locales'))) {
// redirect to current page with fallback locale
return redirect(url(getCurrentUrlWithLocale(config('app.fallback_locale'))));
}
app()->setLocale($locale);
return $next($request);
}
Hellpers
function getCurrentUrlWithLocale(string $locale)
{
$segments = request()->segments();
$segments[0] = $locale;
return implode('/', $segments);
}
Please sign in or create an account to participate in this conversation.