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.
Binding | {{Translate("Subject", "nl-NL")}} |
---|---|
Output | Onderwerp |
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 |
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
|
Comments
Article is closed for comments.