How to build a multilingual Dynamic Email Template in 6 simple steps. Mail icon with various flags from around the world.

How to Build a Multilingual Dynamic Email Template in 6 Simple Steps

If your business has an international workforce or is based in a multilingual country like Canada, sending multilingual emails is likely a core part of your internal and external communication strategy.

There are many ways to send emails in multiple languages, and in this guide, we will walk through all the steps to create multilingual dynamic emails using a combination of Salesforce Marketing Cloud (SFMC) drag-and-drop tools like Content Builder and AMPscript.

For the purpose of demonstration, we have created a simple email series that includes two emails, and each has an English and French version; however, all the steps can still apply if you have more than two languages.


Step 1: Build complete emails for one language

You can build your HTML emails using Content Builder or a text editor like Visual Studio Code. If you prefer a no-code method, then Content Builder will be your go-to option. Here we have built two simple emails using Content Builder. Make sure to test how your emails look across different email clients (Apple Mail, Outlook, Gmail) using a rendering tool like Litmus.


Step 2: Break down the emails into content blocks 

If your emails are built using Content Builder, you can easily break them down into blocks by clicking on each section > Save Block (bottom left) > Create New > Enter a name > Choose a location > Save.

If your emails are built using a text editor, it will be a bit trickier to break them into content blocks. One tip is to mark the start and end of each section with comments and create HTML blocks out of them. 

When all content blocks for the English language are created, we can just duplicate them and swap the English copy with the French copy. And boom! We have all the blocks ready for use.

The two keys for this to work are your naming convention and folder structure. In this example, the first and second emails are respectively stored in the folder “Email 1” and “Email 2” which are located under Content Builder/Restobar/. All of the blocks for each email are stored in the folders called “Localized”. 

Block names are made up of 2 elements: section name and language which are separated by an “_”. Below will better demonstrate the naming convention for email 1. The same approach can be used for email 2. One note is that because all emails will share the same footer, this section does not have to be “localized”. 


Step 3: Create a data extension for dynamic subjects and preheaders

We also need to think about how to create dynamic subjects and preheaders. One simple way to do this is to create a data extension to store all the subjects and preheaders. In this case, we will name it “RestoBar_Subjects_Preheaders”. Each Data Extension row includes a column with the email name and corresponding language. The Lookup() function can then be used to dynamically output subjects and preheaders based on the email number and language. Note the following arguments passed to the function:

  1. RestoBar_Subjects_Preheaders: the Data Extension Name
  2. Subject: Name of the column from which to return a value
  3. Email: Column name that identifies the row to retrieve
  4. Substring(…) : A nested function that retrieves the email number (1 or 2) from the email name
  5. Language: Additional column name that identifies the row to retrieve
  6. Language: Attribute from the sendable Data Extension

Note that due to the Order of Operations (the order in which AMPscript is interpreted), it’s necessary to make these two separate lookup calls rather than retrieve a rowset, as the preheader is interpreted first.

For all subject lines: 

%%=Lookup(‘RestoBar_Subjects_Preheaders’, ‘Subject’, ‘Email’, Substring(emailname_, Add(IndexOf(emailname_, ‘Email_’), 6), 1), ‘Language’, Language)=%%

For all preheaders: 

%%=Lookup(‘RestoBar_Subjects_Preheaders’, ‘Preheader’, ‘Email’, Substring(emailname_, Add(IndexOf(emailname_, ‘Email_’), 6), 1), ‘Language’, Language)=%%


Step 4: Create a “localization” code snippet

For SFMC to programmatically pull the content blocks for each email, we will create an AMPscript code snippet to handle the “localization”. In this case, the code snippet has been automatically assigned an id of 169809 which can be passed into the function ContentBlockByID() to make it reusable. Note that using ContentBlockById() over an alternate content block function (like ContentBlockByKey() or ContentBlockByName() ) is recommended where possible, as this function is more performant at send-time.

Each content block is retrieved based on its full folder path (set by the @contentPath variable) which is made up of base path, email number, block name, and language.


Step 5: Create dynamic content blocks 

Now that we have all the components we need, let’s start creating the multilingual template for email 1. We can duplicate email 1; and delete all the content blocks except for the footer. To output the “Welcome” section, you can drag an HTML block into the template, and paste the following piece of code. 

Repeat this for the remaining sections and change the section’s name (@section). Your template should look something like this: 


Step 6: Preview and test your template

To preview your email, you need to have a sendable data extension. For demonstration purposes, we already created a very simple data extension below: 

You can preview your email in Content Builder by navigating to the “Preview and Test” tab > select the send data extension > click on any subscriber record > Select (bottom right). If you follow all of these steps, your template should automatically swap content blocks when the Language field value changes, and you can repeat this for email 2.



This approach is great for scale but note that if you want to change a file name you will also have to change the section name (@section) in all templates that are using that file, or the function ContentBlockByName() will not work. If you need help with marketing automation, contact us for more information. 


You may be interested in

Getting the most value out of your Salesforce Unlimited Investment

Purchasing Salesforce Unlimited is a significant investment in your day-to-day business operations. This post will dive into how you can make the most of your new investment (or one you’ve already made) and what makes Salesforce Unlimited stand out from Salesforce Enterprise Edition. Sales Cloud and Productivity Features One of Sales Cloud Unlimited Edition’s key […]

Read More

Document Generation in OmniStudio

Streamlining document generation is a pivotal aspect of ensuring efficient business operations. Salesforce OmniStudio provides a robust solution through its Document Generation feature, offering organizations the capability to effortlessly create personalized, professional documents without using code. In this blog post, we will delve into the concept of Document Generation, illustrate a practical business scenario, and […]

Read More

Sign up for the latest tips & news from CloudKettle

Thank you for subscribing.