I'm working on a website, which uses french at default language. I'm new on Laravel, and I have to continue the work of somebody else. I want the users to be able to switch the site in english. Everything works fine, unless, the 'en' prefix won't go from the url, even when I switch back to french.
Anyone ever had the same issue ?
Route::group(
[
'prefix' => LaravelLocalization::setLocale(),
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect', 'localize' ]
], function ()
{
All the localized routes are in this Route::group
My controller is :
public function language(String $locale)
{
\Session::put('lang', $locale);
return redirect()->back();
}
My middleware is
public function handle($request, Closure $next)
{
if ( \Session::has('lang')) {
\App::setLocale(\Session::get('lang'));
}
return $next($request);
}