I have an endpoint to switch the lang:
{{base_url}}/localize/{lang}
So, The controller
class LocalizationController
{
if (!is_null($lang) && !empty($lang)) {
App::setLocale(request('lang'));
}
}
But, It seem not working with API. I really appreciated with your help if you have any idea please help me out.
I prefer to use headers for that task. Create new middleware and check it for all requests.
You can choose your own type of localization like
en
oren_US
or whatever. Then just add header to all your requests like:Accept-Language: es