Answer the question
In order to leave comments, you need to log in
How to localize email templates in laravel?
By default, laravel uses the following file structure:
/resources/views/emails/$template.blade.php
I need to have templates in different languages (locales), if there is no template in any language, the template should be taken from the default locale.
I can't find anything similar in native laravel, I don't believe that there is no plugin that would implement this. I don't want to write a bike. Please, advise the decision if who faced.
Or advise, please, how it is better to implement the mechanism for such behavior. Should I extend the view factory that the mailer uses or use events from the view factory to change the template name?
Answer the question
In order to leave comments, you need to log in
You can use the so-called cascading view. For the template finder, add a directory with localized versions, in case of a miss, it will look in other places.
And why not satisfied with the standard version of the translation? Through json it will work fine.
https://laravel.com/docs/6.x/localization
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question