hello all in my laravel app I have language translation option. English and French.
So In my lang
folder I have en
and fr
folders. Each folder I have a file called, sentence.php
where I store my translation array.
Sample code as follows,
en>sentence.php <?php // sentence.php return [ 'welcome' => 'Welcome', fr>sentence.php <?php // sentence.php return [ 'welcome' => 'Bienvenue ',
Normally I display my translations in my views like this
{{ __('sentence.Welcome') }}
THE ISSUE
Now guys my issue is, I’m sending an custom email to my users with some activation instructions. And I’m failing to translate that email using my regular method.
public function toMail($notifiable) { return (new MailMessage) ->line(''.('sentence.We have successfully created your user account').'') ->line(''.('sentence.Thank you for joining with us!').''); }
out put of this first line is,
sentence.We have successfully created your user account
How can I translate this properly, what i’m doing wrong?
I’m using laravel 7
Advertisement
Answer
Just shooting from the hip:
public function toMail($notifiable) { return (new MailMessage) ->line( __('sentence.We have successfully created your user account')) ->line( __('sentence.Thank you for joining with us!')); }
But this doesn’t seems to be Laravel mail for me. Lara has a very nice mailbuilder out of the box (Markdown) which you can build from components, and also you can send raw mails.