My laravel web application runs in two different languages and I'm using a route to set it, like this:
Route::get('/br', function (Illuminate\Http\Request $request) {
return Redirect::to('/')->withCookie(cookie()->forever('locale', "pt-br"));
});
This works well, but does not work for all the pages on the website, just for the route itself (myapp.com/br)
I want to send my users links on their language, using a url string to define it, and then redirecting the users to the page itself, which could be any page, for example:
This would set language to portuguese, and then redirect them to pricing or any other page on the website that has the /pt in the URL.
Basically I need a wildcard check if "/pt" is in the URL, preferrably through routes.
I know I could do this with a url string, like this:
But it seems a bit off my development pattern.
So, I need something like this:
Route::get('/br/%anything', function (Illuminate\Http\Request $request) {
return Redirect::to('/%anything')->withCookie(cookie()->forever('locale', "pt-br"));
});
Is there a way to do it with a route in laravel?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire