Get Free Audit

Backport: Magento 2 Emails Localization in Templates

May 1, 2018

2808 Oleg Semenov

Backport: Magento 2 Emails Localization in Templates

One of the problems that you may encounter while migrating from Magento 1 to Magento 2 is the localization of letters. Usually, it is done simply by copying an email template to the appropriate folder. But what are you supposed to do if you have a multilingual site?

Method 1

This method is available in Magento 1 and implies the creation of new letter templates via Marketing > Email Templates.

image4

Here you can create additional email templates, translate them, add additional text, etc.

After that you can assign these templates in the settings of a particular Store View.

image6

You can do it for each email template.

This method is fairly simple, but can take quite some time.

During one of my project I did a backport of Magento 1 functionality, which somehow disappeared in Magento 2, specifically the assignment of your templates to a specific language. Earlier they were located in the folder with translations.

Method 2

Here is what you need to do to implement similar functionality in Magento 2:

  1. Override the Magento\Framework\View\Design\Fallback\RulePool class in one of your modules or a new one. In this class, you need to extend the createEmailTemplateFileRule method.


RulePool.php

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

  1. After that we can place our templates in the theme or in the module at <module_dir>/view/<area>/email/i18n/<locale> or <theme_dir>/<module_name>/email/i18n/<locale>.

image2

Just like that you can save some time and effort when working with your email templates.

You can also check out our recent article Email templates in Magento 1.9 to learn more about email templates in Magento. This is one of the topics at Magento front end developer certification, so it’s worth taking a look at it.

Looking for great Magento extensions? Visit BelVG Magento extensions store!

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

2 Comments

  1. Thank you, Maulik!
    We have plenty of good articles, stay tuned! :)

  2. Thanks for showing best of mathods for localization of email templates. Its really worth implementing.

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *