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
{{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.
Thank you.