translate notifications
i send notification to user with this code
app language is italian
user language is english, his ui is all translated in english but notification are sent in italian...
if admin UI is set to english, notification are sent in english
any suggestion?
thanks
7 Replies
you need to send the user the notification in their language, not yours
so set the locale to the users locale before sending
there is a way to do it here
you can do:
app()->setLocale($userLocale);
use
setLocale
whereever you want to change the locale for the next code block
and set it back to the original locale
ok, to do in this way i need to make 2 different (but equal) if
one for customer one for tech, but it's ok
thansk
I think if you implemented User Preferred Locales
https://laravel.com/docs/11.x/notifications#user-preferred-locales
the notification will be set depend on the user locale
only if you're using
broadcast
or toDatabase