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 or the 'DocumentLanguage' cannot be found, or if no value exists for the language in the Translations data source, the value of the Name column will be used instead.

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.

Binding {{Translate("Subject", "nl-NL")}}
Output Onderwerp

  Important

  • If the nl-NL column is not found, then the output would be "Subject" as it defaults back to the value existing in the Name column of the Translations data source.
  • 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

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.

 

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.