lundi 28 janvier 2019

Laravel 5.5 Localization in Route

we're trying to route to different languages, but isn't working that well currently.

We work with Language folders

We have currently: example.com/hotelA (if someone access this it automatically changes the language according to IP.

Now we would like to have direct links for the all languages: example.com/en/hotelA/ example.com/tr/hotelA/

We solved the switcher in button of our page like this:

Route::get('language/{locale}', function ($locale) {
        App::setLocale($locale);
        Session::put('locale',$locale);
        Session::put('custlocale',$locale);
        return back();
});

But this is only working when some triggers the button. So we tried:

Route::get('/{locale}/{slug}/', 'frontEnd\HotelController@showHotel'), function ($locale) {
        App::setLocale($locale);
        Session::put('locale',$locale);
        Session::put('custlocale',$locale);
        return back();
});

Isn't working really. So we tried many other things but we couldn't solve it properly. Any idea how to solve this properly? Maybe best practices?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2sSQqUG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire