in my laravel project I want to have multiple languages. I know there is a lang folder where you can store your different language templates and other things.
the problem is :
My domain is : example.com
and by default I want "EN" as my main language
I want to add a link in website header for "FR" language and by clicking that, a "FR" will appears in url so the user will understand that he changed the language. but we he clicks on "EN", there are no "EN" in the url and the default domain will be shown.
I will try to answer the question. Laravel actually provides a very clean way to do this. So basically you need to do App::setLocale($locale);
to set the default locale for the request session.
Adding a code snippet for some clarity from here:
Route::get('welcome/{locale}', function ($locale) {
if (! in_array($locale, ['en', 'es', 'fr'])) {
abort(400);
}
App::setLocale($locale);
});
If you don't use this method "en" would always be used a default fallback.
Now, coming to the second part where you want to change the url for "en" particulary. In such case you can just add a redirect.