Hi there, I have an app that is supposed to be available in two different languages. We might want to add another language at some point.
I am supposed to implement notifications and they are supposed to be in the same language the user selected : if the user has selected french, then the notification should be available in french.
That also means the notification text (that is, the text the user sees) will be translated if the user selects another language after receiving a notification. Each type of notification has the same text (GroupInviteNotification will always read as ":user has invited you to join :group", for example).
What would be the best way to implement this, given my translations are in the lang folder (as prescribed by laravel documentation) ?
you have two possibilities: either with the Blade-directive @lang or with the php-method trans() (I guess the latter was replaced by __() in 5.4, but trans() still works.
as parameters you pass filename.stringname (as set in the lang folder) and the values for your placeholders as an array.
Hey dunsti, thanks for your answer. I am using __() but couldn't wrap my head around how I should map a notification to a multilingual file until now.
What I have done is include the translation key (that is messages.welcome in your example) into my notification. Thanks !