I'm trying to accomplish:
no locale in url for the local set in config.php when a language is selected the local is set in the url What I have in code:
kernel.php
protected $routeMiddleware = [
// Locale REDIRECTION MIDDLEWARE
'localize' => 'Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes',
'localizationRedirect' => 'Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter',
'localeSessionRedirect' => 'Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect'
routes.php
Route::group(['prefix' => LaravelLocalization::setLocale()], function()
{
//------- ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP -------//
Route::get('/', 'HomeController@index');
Route::get('home', 'HomeController@index');
Route::get('welcome', 'WelcomeController@index');
});
config/laravellocalization.php
'useAcceptLanguageHeader' => true,
'hideDefaultLocaleInURL' => true,
What is happening: The language selector uses code as per readme and will switch the url to "es/home" and will translate the page correctly. When I click on the link "/home" the language returns to English.
What am I doing wrong? Do I need to code or set my urls a certain way? If so would you mind providing some code?
I did look at the blog app that mcamara has in his repositories but it sets all urls as "en/home" or "es/home" which isn't really what I am trying to do so I didn't download and install to use as a learning source.
Thanks!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community