This article explains how to create a document language field in the User Profile.
The document language is used in many functions like FormatDateTime() and Translate() as well as to set the proofing language. It is recommended to use 'DocumentLanguage' as the name of the variable.
Prerequisites
|
Add languages to the Languages data source
Before you create a document language field in the User Profile, first add languages to the Languages data source in the Admin Center. Follow the steps below:
- Click on the Resources section of the Admin Center.
- In the upper right corner click More options and then Settings.
- In the dropdown select the language(s) you want to use, for example:
Important
Only use languages with a 4 letter code like
en-US
orfr-FR
. Languages with 2 letter codes likeen
orfr
are not supported as they might cause unexpected behavior when users click Update document. - Click Save to save the languages.
- The selected languages are now automatically added to the system-generated data sources Languages and Translations:
- You can add values to the Translations data source like the translations for 'Subject' in the image above (optional).
Create a document language field in the User Profile
The next step is to create a document language field in the User Profile. Follow the steps below:
- In the Admin Center select the Users section, then go to the User Profile tab and click Edit form:
- Click + Add form field.
- On the General tab, in the Type field select Dropdown, then in the Name field type 'DocumentLanguage' (without quotes).
- In the Label field type any text, for example 'Document language'. The result looks like this:
Important
- The name DocumentLanguage (exact casing and without a space) is a reserved word within Templafy.
- Whenever a document language is required in a (Dynamics) binding and the variable is omitted, Templafy will look for a DocumentLanguage field in the User Profile. If a field with this name is not present, then e.g. dates will always be shown in English notation, even when the selected language is e.g. Dutch or French.
- It's recommended to always use 'DocumentLanguage' as value in the Name field.
- On the Configuration tab, in the Options dropdown select Languages then in the Field to show field select Name. The result looks like this:
- Click Add field.
- Click Publish.
Examples
Example 1
When the recommended name DocumentLanguage is used in the User Profile, then these are the results in combination with a FormatDateTime() binding with the date '15 May 2023' and the language set to 'Dutch (Netherlands) (nl-NL)':
Binding | Output |
---|---|
{{FormatDateTime(Form.Date, "d MMMM yyyy", DocumentLanguage)}} | 15 mei 2023 |
{{FormatDateTime(Form.Date, "d MMMM yyyy")}} | 15 mei 2023 |
Note
|
Example 2
The same values from Example 1 are used, but this time MyLanguage is used in the User Profile instead of the recommended name DocumentLanguage:
These are the results:
Binding | Output |
---|---|
{{FormatDateTime(Form.Date, "d MMMM yyyy", UserProfile.MyLanguage.Language)}} | 15 mei 2023 |
{{FormatDateTime(Form.Date, "d MMMM yyyy")}} | 15 May 2023 |
Note
|
Example 3
In this example this data source is used:
When the recommended name 'DocumentLanguage' is used in the User Profile, then these are the results in combination with a Translate() binding with the text 'Subject' and the language set to 'Dutch (Netherlands) (nl-NL)':
Binding | Output |
---|---|
{{Translate("Subject", DocumentLanguage)}} | Onderwerp |
{{Translate("Subject")}} | Onderwerp |
Note
|
Example 4
The same values from Example 3 are used, but this time 'MyLanguage' is used in the User Profile instead of the recommended name 'DocumentLanguage':
Binding | Output |
---|---|
{{Translate("Subject", UserProfile.MyLanguage.Language)}} | Onderwerp |
{{Translate("Subject")}} | Subject |
Note
|
Comments
Article is closed for comments.