I am developing a page which will have multi-language Spanish and English , for front-end
I am using vue-i18n
. In front-end
I send the active language every time I need some data of back-end
The problem
When I choose the language, I send the selected language to back-end
, then I save it in sesion
, but when I need laravel
to return a message in the selected language, it returns it in Spanish (default language) ).
Try this in AppServiceProvider
app()->setLocale(session()->has('lang') ? session()->get('lang') : 'es');
when I review the session it shows null
.
When I save the session I save it like this
session()->put('lang', $request->input('lang'));
// o
session(['lang' => $request->input('lang')]);
return response()->json([
'lang' => app()->getLocale()
]);
why is the session not being saved? try using cookie
or file
in the driver and the problem persists.