Reputation: 1378
I have a custom magento sales module. I want to translate the custom mail template located in my local module folder(mailtemplate/template1.html). I copied it from the locale/en_US/template/email/sales folder.
I want to replace the placeholders with the customername and telephone number. And translate the message according to the customers country.
Also wanted to check if the telephone number has international country code and add the code, if not present, according to the customers country.
How do i translate text in magento.
Upvotes: 3
Views: 10539
Reputation: 44
Magento2 - How to Translate Order Emails
To support the translation of content, all strings in emails are output using the trans directive. For example,
{{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}
{{trans "Once your package ships we will send you a tracking number."}}
The trans directive will translate strings into whatever locale is configured for the store from which the email is being sent. For example, if an email is being sent from a store view that is configured to use the fr_FR locale, the emails will be translated into French.
The directive supports multiple named parameters separated by spaces. For example,
{{trans "Dear %first_name %last_name," first_name=$first_name last_name=$last_name}}
Tutorial from: https://themes.email/magento/how-to-translate-magento-order-emails.html
Upvotes: 1
Reputation: 27119
To translate an email, you can copy it from the en_US folder to a corresponding language folder (es_ES, for example), then perform the translation. When you do this, you can also add or remove other vars from the email. Most emails will have headers that show you what vars are available.
As for adding a country code to the telephone number, you will need to define a new block in a module that will do this for you.
Upvotes: 5