A
A
Alexander2015-06-03 10:31:48
Internationalization and localization
Alexander, 2015-06-03 10:31:48

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

2 answer(s)
V
Vyacheslav Plisko, 2015-06-03
@AmdY

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.

G
gian_tiaga, 2019-09-28
@gian_tiaga

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 question

Ask a Question

731 491 924 answers to any question