I am trying to implement multilingualism on the site under laravel 5.4.
Locale to show
Route::get('setlocale/{locale}', 'HomeController@language'); public function language($locale){ if (in_array($locale, \Config::get('app.locales'))) { // Проверяем, если у пользователя выбран доступный язык Session::put('locale', $locale); // Устанавливаем его в сессии под именем locale } return Redirect::back(); } If in the blade insert {{\Session::get('locale')}} , then I get the desired value (say ru)
And if you insert such code in __construct
if (Session::get('locale') != null) { $lang = Session::get('locale'); } else if (Session::get('locale') == null) { $lang = "null"; } View::share('lang', $lang); , I get null. I break my head, I can not understand why!?
Naturally in the controller are connected
use View; use Session; Help please understand why __construct does not give the value of Session::get('locale') . thanks in advance