Multi-language Templates (MLT) empower your end users to design customized experiences for their international audiences. Through the use of this feature, your end users will be able to select one default language, and up to 20 translations reflected in the top bar of their builder. Keep in mind that Multi-language Templates provide you with a means to translate template content, but does not automatically translate the content for you.
MLT provides a translation infrastructure, but does not perform the translation for each language version of your template. You can integrate translations into your application for each language version using one of the following two methods:
Enable the , which gives your end users access to a Translate button within the builder. When your end users click this button, all the translatable fields will automatically translate to the language corresponding with the template's language version. Note: MLT is a prerequisite for enabling the .
Enable the to allow your end users to translate their template language version's content with the .
End users can type the translations manually for each template language version.
Note: The style of your templates stays the same across the language version while MLT is in use. The only change that will occur is the language of the text for the relevant components.
This Configuration Guide will help you get started with configuring the MLT feature. We recommend you start with the section to ensure you have everything you need for a successful configuration.
If you are uncertain if your host application is a good candidate for this functionality, continue to the section to learn more about this feature.
Is MLT for Your Application?
The Multi-language Templates (MLT) feature is an enhancement for companies working with end users who build emails that engage with international audiences.
MLT adds the following extended functionality to your host application:
Add a new language for the content inside Beefree SDK
Activate the language configuration in the
Customize a list of languages the user can choose from
To use Multi-language Templates, your host application only needs to store one JSON file with the languages. For more information on this, visit the .
For more information on the end user experience for Multi-language Templates, visit our .
End User Functionality
Multi-language Templates (MLT) offers the following in-app features for an application end user:
Switching the editor and template languages
Translate contents
View a list of eligible content in the .
For more detailed information on the MLT feature offering, visit our Multi-language Knowledge Base article.
Before proceeding with the configuration, ensure you have:
Superpower or Enterprise plans
The multi-language support toggle set to on in the Beefree SDK Console
Configuration Steps
To use Multi-language Templates, your host application only needs to store one JSON file with the different languages you’d like to offer. Take the following steps to configure Multi-language Templates (MLT) in your application.
Enable multi-language templates
Click “Details” on the application you’d like to enable multi-language template for.
Select “Application configuration”.
Initialize multi-language templates
Add the templateLanguage property to the config object. This property defines the default language for the template.
Add the templateLanguages property to the config object. This property defines the list of language options for the template translations.
The following example shows the properties within the config object. In this example, the languages are read and written from left to right.
Note: You can only choose languages that are written and read from left to right, or right to left. You cannot mix languages with different directions of reading and writing within the same JSON.
The following sample shows an example of a default language and three translation languages that are written and read from right to left.
Note: If you're on a Superpowers plan, you can have up to six additional language versions of the design using one template. If you're on an Enterprise plan, you can add up to 20 translation languages.
The lang attribute on the content modules helps with .
Test the Configuration
Once you have initialized multi-language templates, you can confirm that the configuration was successful by following these instructions:
Confirm whether or not you see a language drop-down menu.
If you see a drop-down, the configuration was successful. If you do not see a drop-down, reference the following table for troubleshooting steps you can take.
Issue
Description
Resolution
Translation HTML
Multi-language Templates (MLT) offer the option to save and export translation HTML. This section outlines the steps you need to take to save or export a translation’s HTML.
To save the HTML output for a specific language take the following steps:
Use the bee.save method and provide the desired language as a parameter. In this example, we’ll save it for the Italian language (‘it-IT’).
Set up an onSave event listener to handle the HTML saving process. This listener will be triggered when the HTML generation is complete. You can add it to the configuration object.
In the code above:
onSave is an event handler function that takes several parameters related to the generated HTML.
pageHtml contains the generated HTML.
language contains the requested language value, which was previously set in the bee.save
If you want to use the default main language for generating HTML when the bee.save method is called without parameters, you don’t need to specify a language in the bee.save method. The default language will be used automatically.
Export Translations
Take the steps outlined in this section to export the translation HTML.
Define an array of languages that you want to export translations for. Each language should be represented as a string.
The following example shows an array of multiple export languages.
Create a function, let’s call it exportAllTranslations as an example, which will iterate over the array of languages and call the bee.save method for each language.
View the following example function.
Implement the onSave callbacks for each language. These callbacks will be triggered when the bee.save method completes for each language. Make sure to handle the specific language-related data within each callback.
To get HTML in a specific language by our , ensure you include a “language” key/value pair to the body of your request. Ensure you reference the instructions for using the of the to learn more about exporting template HTML.
The following sample code displays this:
Changing the Language
Follow the steps outlined in this section to create a specified functionality that allows the end user to change their template language when a custom top bar is enabled.
Create a function to handle the language change. You can use the instance method bee.switchTemplateLanguage for this purpose.
Verify if the specified language exists in the available languages. If it does, the language switch will happen automatically.
Note: If the specified language does not exist among the available languages, an event will be fired to the onError callback.
Once the language is successfully changed, a callback named onTemplateLanguageChange will be triggered.
You need to define this callback function to respond to the language change.
The onTemplateLanguageChange callback will receive an object (lang) containing information about the language the user switched to. This object will have three properties:
label: The label or name of the language.
value: The value representing the language (e.g., ‘es-ES’ for Spanish).
Test the language switching functionality by calling bee.switchTemplateLanguage with different language values, and make sure that the onTemplateLanguageChange callback responds correctly.
Triggering the Translation Preview
If you have a custom Preview, you can handle switching languages on the Preview.
To open the Preview, you can call either of two methods:
The methods perform the following tasks:
togglePreview: a toggle that opens and closes the Preview.
switchPreview: accepts a parameter to specify the language and get the HTML preview. It also opens the Preview if it’s closed.
The following code shows an example of the methods applied for the default language.
The following code shows an example of the methods applied for a preview in French.
Note: The language parameter is optional in switchPreview. Calling it without parameters will open the Preview with the default language selected. If the Preview is open, nothing will happen. The same behavior is applied when the language passed is not valid or doesn’t exist.
Automating Translations
If you would like to provide your end users with the option to automatically translate all of the translatable content within their design, you can use the .