Articles in this section

How to translate terms or sentences using Translate()

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

  • Library and at least one Dynamics module enabled.
  • Templafy Desktop and Office VSTO add-in installed on the PC.
  • Space owner access to the Templafy tenant.
  • Languages were added in the Admin Center and the Translations data source is populated.

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

  • The Translate() function is case-sensitive.
  • If the ColumnName does not exist in the Translations data source (e.g. there is no de-DE language column, while your binding refers to that language) or the 'DocumentLanguage' in the User Profile is empty, the output is the original term you are trying to translate.
  • If the ColumnName does exist but has an empty value, the output is the empty value.

Translate() function examples

The data sources and User Profile field below are used in the examples.

Languages data source:

translatelanguages.png

Translations data source:

translatetranslations.png

  Note

The language columns are automatically created when adding languages to the tenant.

User Profile using 'DocumentLanguage':

translateuserprofile.png

  Important

The 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

  • If the nl-NL or fr-FR column is not found, the output would be "Subject" as it is the original term you are trying to translate.
  • As the Translate() function is case-sensitive, the name in the Translations data source needs to be "Subject" (not "subject").

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

  Important

When 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

  • The binding {{FormatDateTime(Form.Date, Translate("FormatLongDate", UserProfile.DocumentLanguage.Language), UserProfile.DocumentLanguage.Language)}} can also be used.
  • If the 'DocumentLanguage' is not set then an unexpected value ('or0aALonA.D.DaAe') is shown (because the system tries to format the text 'FormatLongDate' as a date). The solution is to make the 'DocumentLanguage' field required.

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

  • Because the column fr-FR has an empty value, the output is the empty value.
  • Because the column de-DE does not exist, the output is the original term "Copyright" you are trying to translate.

  Tip

See 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

  Important

Because 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")}}:

translatedisclaimer.png

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

  • Because the column fr-FR has an empty value, the output is empty.
  • Because the column de-DE does not exist, the output is empty.
proper question proper case propercase readback column readback readback order tech_role
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.