Ad

Laravel 5.1 Localization Not Working

- 1 answer

I have some issue with the localization in laravel 5.1 I have inserted the various langs files in the main lang folder. There, i have "en" folder and "ru" folder etc..

ex:

home.php:

return [
 'something' => 'something testing',
]; 

In the route i have this GET:

get('/gui/{lang}/{id}/{ver}/',['as' => 'gui', 'uses' => '[email protected]']);

but the langs didn't change. if i change the route URL the text stays always in the "en" default lang.
some example:

http://domain.com/gui/en/1/home

http://domain.com/gui/ru/1/home

Ad

Answer

I advise you to read the docs, because it seems to me you haven't done that.

On your [email protected] you have to set your locale,

public function home($lang, $id, $ver){
    App::setLocale($lang)
    echo trans('home.something');
}
Ad
source: stackoverflow.com
Ad