Multi-Language Templates
Multi-language Templates are only available for Superpower and Enterprise plans.
Overview
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 six 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 DeepL AddOn, 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 DeepL AddOn.
Enable the AI Writing Assistant AddOn to allow your end users to translate their template language version's content with the AI Writing Assistant.
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 Prerequisites 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 Is MLT for Your Application? 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 Beefree SDK configuration file
Customize a list of languages the user can choose from
Allow changes to the default language
Enable preview for templates in different language versions
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 Configuration Steps section.
For more information on the end user experience for Multi-language Templates, visit our Multi-language Templates white label end user documentation.
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 Translate Contents section of the Multi-language Knowledge Base Article.
Multi-language Template preview
Export HTML for multiple languages as single files
Alternative text descriptions
Changing an image path
This lets users switch email images for different translations. For instance, they can replace an image containing English text with the corresponding image containing Spanish text for the Spanish translation.
For more detailed information on the MLT feature offering, visit our Multi-language Knowledge Base article.
Prerequisites
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
Application Client ID
Application Client secret
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
Log in to the Beefree SDK Console.
Click “Details” on the application you’d like to enable multi-language template for.
Select “Application configuration”.
Navigate to the multi-language template toggle.
Toggle the feature to on.
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.Confirm you added both properties with the correct language options and save your changes.
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: You can have up to six different versions of the design using one template.
Languages are defined with a value and a label. The label is what will be shown in the language drop-down inside the top bar. The value is a key that stores the translations in the JSON. It is used to set the corresponding language meta attribute for each translation.
Lang Attribute
The lang attribute on the content modules helps with hyphenation and screen readability.
Test the Configuration
Once you have initialized multi-language templates, you can confirm that the configuration was successful by following these instructions:
Go to your builder.
Navigate to the top bar.
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.
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.
Save 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
method.
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 thebee.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 CSAPI, ensure you include a “language” key/value pair to the body of your request. Ensure you reference the instructions for using the /html
endpoint section of the Content Services API Reference 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.
Ensure you have a custom top bar.
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).isMain
: A boolean property indicating whether the selected language is the default one, as defined withtemplateLanguage
in the configuration object.
Test the language switching functionality by calling
bee.switchTemplateLanguage
with different language values, and make sure that theonTemplateLanguageChange
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:
bee.togglePreview
bee.switchPreview
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 DeepL addOn.
Last updated