This article explains what the Translate() function is and provide examples of how it can be used with the binding syntax in smart templates.
Prerequisites
|
What is the Translate() function?
Translate() is a function that allows the translation of specific terms or complete sentences by returning specific values from the Translations data source. When using the Translate() function, the value present in the Name column of the Translations data source will be used to resolve the value from the desired language column.
Translate() logic
| Syntax | {{Translate(NameValueToLookUp, ColumnName)}} |
|---|
-
NameValueToLookUp: Must be present in the Name column of the Translations data source and is used to identify the row that should be used for the translation. -
ColumnName: Is used to resolve the desired language column.
If the User Profile contains a 'Language' dropdown with the Name 'DocumentLanguage', a simplified syntax can be used that will automatically use the language column set in the User Profile:
| Syntax | {{Translate(NameValueToLookUp)}} |
|---|
Important
|
Translate() function examples
The data sources and User Profile field below are used in the examples.
Languages data source:
Translations data source:
NoteThe language columns are automatically created when adding languages to the tenant. |
User Profile using 'DocumentLanguage':
ImportantThe word 'DocumentLanguage' is a reserved word within Templafy. If you use this in the Name field, it can be used in many bindings, for example to set the proofing language. |
Example 1
Using the Translate() function to translate "Subject" to Dutch or French.
| Binding | {{Translate("Subject", "nl-NL")}} | {{Translate("Subject", "fr-FR")}} |
|---|---|---|
| Output | Onderwerp | Sujet |
Important
|
Example 2
Using the Translate() function to translate "Subject" based on the 'DocumentLanguage' set in the User Profile.
| Binding | {{Translate("Subject", DocumentLanguage)}} | ||
|---|---|---|---|
| Input | DocumentLanguage = "nl-NL" | DocumentLanguage = "fr-FR" | DocumentLanguage = not set |
| Output | Onderwerp | Sujet | Subject |
Note{{Translate("Subject")}} could have also been used to resolve the language set in the User Profile with the 'DocumentLanguage' field. |
Example 3
Using the Translate() function to translate "Subject" based on the 'DocumentLanguage' selected by the user in the response form.
| Binding | {{Translate("Subject", Form.DocumentLanguage.Language)}} | ||
|---|---|---|---|
| Input | DocumentLanguage = "nl-NL" | DocumentLanguage = "fr-FR" | DocumentLanguage = not set |
| Output | Onderwerp | Sujet | Subject |
ImportantWhen the 'DocumentLanguage' in the User Profile is not set (empty), the output is the original term you are trying to translate. |
Example 4
Using the Translate() together with FormatDateTime() function to show a specific date format depending on the 'DocumentLanguage' set in the User Profile.
| Binding | {{FormatDateTime(Form.Date, Translate("FormatLongDate", DocumentLanguage), DocumentLanguage)}} | ||
|---|---|---|---|
| Input |
Date = 4 October 2021 DocumentLanguage = "nl-NL" |
Date = 4 October 2021 DocumentLanguage = "fr-FR" |
Date = 4 October 2021 DocumentLanguage = "en-US" |
| Output | maandag 4 oktober 2021 | lundi 04 oct. 2021 | Mon 4 October 2021 |
Important
|
Example 5
Using the Translate() function to display a copyright text in English, French or German.
| Binding | {{Translate("Copyright", "en-US")}} | {{Translate("Copyright", "fr-FR")}} | {{Translate("Copyright", "de-DE")} |
|---|---|---|---|
| Output | © 2025 All rights reserved. | empty | Copyright |
Important
|
TipSee this article for other ways to display copyright text in a document or presentation. |
Example 6
Using the Translate() function to translate "Description" to Dutch or French.
| Binding | {{Translate("Description", "nl-NL")}} | {{Translate("Description", "fr-FR")} |
|---|---|---|
| Output | Description | Description |
ImportantBecause the term "Description" does not exist in the Name column of the Translations data source, the output is the original term "Description" you are trying to translate. |
Example 7
Using the Translate() function to insert a (disclaimer) text element based on the 'DocumentLanguage' set in the User Profile.
In the Asset ID field of the template use the binding {{Translate("Disclaimer")}}:
| Binding | {{Translate("Disclaimer")}} | ||
|---|---|---|---|
| Input |
DocumentLanguage = "en-US" |
DocumentLanguage = "nl-NL" |
DocumentLanguage = not set |
| Output | Text element with asset ID '637493247912345678' (disclaimer written in English) | Text element with asset ID '637493247987654321' (disclaimer written in Dutch) | empty (no text element inserted) |
Note{{Translate("Disclaimer", DocumentLanguage)}} could have also been used to resolve the language set in the User Profile with the 'DocumentLanguage' field. |
Example 8
Using the Translate() function to insert a (disclaimer) text element in English, French or German:
| Binding | {{Translate("Disclaimer", "en-US")}} | {{Translate("Disclaimer", "fr-FR")} | {{Translate("Disclaimer", "de-DE")} |
|---|---|---|---|
| Output | Text element with asset ID '637493247912345678' (disclaimer written in English) | empty (no text element inserted) | empty (no text element inserted) |
Important
|
Comments
Article is closed for comments.