'Pass locale string to Lang::get method in laravel
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'] ]);
Solution 1:[1]
get() method accept lang code at the third parameter
Lang::get('newMatchBody', [ 'userName' => $this->receiver['name'] ],'en');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Omar Tammam |
