F
Filament2mo ago
ericmp

Filament ResetPassword notification - set locale correctly

i do:
app()->setLocale('ca');

$user = User::query()->where('email', '[email protected]')->first();

$token = \Illuminate\Support\Facades\Password::getRepository()->create($user);

$notification = new \Filament\Notifications\Auth\ResetPassword($token);
$notification->url = \Filament\Facades\Filament::getResetPasswordUrl($token, $user);

$user->notify($notification);
app()->setLocale('ca');

$user = User::query()->where('email', '[email protected]')->first();

$token = \Illuminate\Support\Facades\Password::getRepository()->create($user);

$notification = new \Filament\Notifications\Auth\ResetPassword($token);
$notification->url = \Filament\Facades\Filament::getResetPasswordUrl($token, $user);

$user->notify($notification);
the email i get is in english. why? im setting the app locale in catalan before sending the notification. why is sent in english? then i saw that in my env i have:
APP_LOCALE=en
APP_LOCALE=en
and if i change the env to:
APP_LOCALE=ca
APP_LOCALE=ca
and i get the email in catalan. but i dont want to change the APP_LOCALE i want the notification to be sent in the language i set before the notification is sent. how to achieve it? i thought doing app()->setLocale('ca') would do the trick, but seems is being ignored
2 Replies
ericmp
ericmpOP2mo ago
seems it relies on the default locale set in the configuration instead of the dynamically set locale in the code bump
Want results from more Discord servers?
Add your server