How to Translate Magento 2 Email Templates
Magento 2 is a widely used open source platform to build E-commerce stores. Therefore, the online stores built in Magento 2 offers a shopping platform to customers all over the globe. When serving such a huge mass, many factors must be taken into consideration, language being one of them!
Every communication taking place between the store and the customer must be in the language that customer can understand. Otherwise, it may confuse them and the store may lose a sale.
Generally, store owners use Emails to communicate with customers. Be it sales Email, newsletter, etc. By default, Magento offers Email templates in English language only. To overcome this limitation, here’s the code to translate Magento 2 Email templates.
Implement the below code in the Email template and the translated Emails will be sent to your customers in the language set in Magento 2 frontend.
Here, the value passed in “trans” is translated. For example, the below code shows {{trans “hi”}} where the text “hi” is translated.
Method to translate Magento 2 Email templates:
Place the below code at [Vendor]/[Module]/view/frontend/email/file.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
{{template config_path="design/email/header_template"}} <!--@subject Thank You For Your Inquiry @--> <!--@vars @--> <table> <tr> <td> <table> <tr> <td valign="top"> <h1>{{trans "Hi"}} {{var name}},</h1> <!-- here {var cname}} is variable name from template variable--> </td> </tr> <tr> <td>{{trans "Thank you for contacting us. Your inquiry has been submitted successfully. We are looking into it and will contact you soon."}} </td> </tr> <tr> <td> <center> <p> <strong>{{trans "Thank you"}}</strong> </p> </center> </td> </tr> </table> </td> </tr> </table> {{template config_path="design/email/footer_template"}} |
That’s simple, isn’t? Use the above method to translate Magento 2 Email templates and easily send Emails without the language barrier.
However, feel free to post your doubts in the Comments section below and I’d be happy to help.
Don’t forget to rate the post with 5 stars if you found it useful.
Thank you.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
2 Comments
How to translate catatlog attribute ? EG. I want to translate Size. Already added label to attribute title but not translating in email also in CSV file in theme.
Hello Vivek,
Using {{trans “Size”}} will solve your issue.
Make sure that the “size” word in the CSV file is according to the module.
Thanks.