Home > Software engineering >  Pass locale string to Lang::get method in laravel
Pass locale string to Lang::get method in laravel

Time:04-07

I'm trying to send some localized notifications to my users on a react-native app with laravel backend, I store user language as string, like "es" or "en", now in my controllers I use Lang::get method, but afaik this always returns the server or app locale and not user's locale (which they can change from app settings).

So the question is, can I pass user locale from frontend to my server Lang::get method?

My code:

$body = Lang::get('newMatchBody', [ 'userName' => $this->receiver['name'] ]);

CodePudding user response:

get() method accept lang code at the third parameter

Lang::get('newMatchBody', [ 'userName' => $this->receiver['name'] ],'en');
  • Related