Loralizing Laravel 5.1

I am new to Laravel, so I am still missing good programming techniques. For my work, I need to localize an application in three languages.

I know where to make the language resource files / lang ... To use them I can write Lang::get('navigation.dining')

. And in my view the file at beginng I define <?php App::setLocale(session('lang'));?>

.

The session is saved by routes.php. Here's an example:

Route::get('language/{lan?}', function ($lan='eng'){
    Session::put('lang', $lan);
    return redirect()->back();
});

      

I'm not sure if this approach is good or not, so please fix it or suggest a better way to do it.

+3


source to share


1 answer


Are you looking for any of these:

app()->setLocale($lan);
App::setLocale($lan);

      



The best practice would be to put them in the Middleware for languages.

0


source







All Articles