简体   繁体   中英

How to handle language support in mandrill template?

I am using mandrill as a mail agent in my .net core application and it is working fine. Now the issue is I have multiple language support in my app (en, dk, sv etc) and I want to add only one template and handle the translations in that. Is this possible using if else or something else. In the api docs ( https://mandrillapp.com/api/docs/ ) I couldn't find anything related to that.

As per Mandrill docs you can use two templates ie mailchimp or handlebars.By default mandrill use 'merge_language'=>'mailchimp' in the message object.If you want to use handlebars then you have to specify 'merge_language'=>'handlebars' in the message object. 在此处输入图片说明

You would need to create two different templates. You can use suffixes.

For example, create two templates for two different languages:

welcome-email-en
welcome-email-de

You can use then your template in format

welcome-email-{{language_suffix}}

just add the suffix according to your selected language in your code and call the Mandrill API. It's easier to use and maintain when you have the same template base for different languages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM