setLabelTranslations
Allows data exported from Salesforce's Translation Workbench to be used in the logic. Currently this command provides automatic translation of labels of picklist values and may optionally store Custom label values into the variable context.
To make use of this command, the Online template needs to contain data exported (ZIP file) from the Translation Workbench. Use the language
attribute to define which language is used from the set of languages defined in the organization.
Picklist values
After this command has been evaluated, labels of Picklist values and Multipicklist values typically found in Data items produced by Salesforce data retrieval commands undergo automatic translation to the defined language. For example, an EL expression referring to the label of an Opportunity's stage, ${opportunity.StageName.label}
, would be affected by this assuming the translation data contains translations for the different stage names. If a translation for avalue is not defined, the expression resolves into the default label.
Please note that at the moment this translation feature does not work for values of picklist fields using global value sets.
Custom labels
The data from Translation Workbench contains data of all the Custom labels in the organization, and so this command can make the values of these labels available in the variable context. Just define the customLabelsVar
attribute and Custom label values in the defined language will be stored there as a Map.
The labels can be accessed through EL with expressions similar to those present in SalesforceLightning Components: the format is ${yourCustomLabelsVar.namespace.labelName}
. For example, with customLabelsVar
of "customLabels", a Custom label in the default namespace called "Test_Label" would be behind the expression ${customLabels.c.Test_Label}
and the Custom label "Flow_info" in the "dynamo" namespace is found with ${customLabels.dynamo.Flow_info}
. The resolved label value will be in the language defined through this command, unless a translation for the label is missing in which case the resolved value is the untranslated, original label value.
Attributes
language | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | String | No |
Defines the code of the language in which the translated values should appear in. Needs to be one of the languages present in the exported Translation Workbench data. Salesforce's documentation page for its SupportedLanguages displays the possible language codes. |
customLabelsVar | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | No |
If defined, Custom label values in the language defined by |
Examples
Assuming you've got suitable translation data present in your template, the data can be put to use like this:
<setLabelTranslations language="de">
Afterwards, picklist value labels are automatically translated (into German in this example), unless the translation data is missing an entry for the requested picklist value. To get the label of the picklist value, use the "label" property:
<span dyn-content="opp.StageName.label"/>
Custom labels can be made available by defining the customLabelsVar
attribute:
<setLabelTranslations language="de" customLabelsVar="customLabels">
The labels can then be used in document content or screens, for example:
<span dyn-content="${customLabels.c.Test_label}">Test label here</span>