For the managed package runtime, display multi-language Omniscripts in OmniOut using custom labels. Access custom labels in your Omniscript directly from Salesforce or use custom labels defined in local files. Control which language displays by using a language code.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
The language code searches locally defined language files or a Salesforce connection to access a language's custom labels. If the Omniscript component tag's run-mode attribute is present and set to localScriptDef, the Omniscript uses the locally defined custom labels. If run-mode isn’t present, the Omniscript accesses the custom labels through a Salesforce connection.
Before You Begin
-
Create a multi-language Omniscript. See Create Multi-Language Omniscripts (Managed Package).
-
Add your multi-language Omniscript to an OmniOut LWC. See Add an Omniscript Lightning Web Component to OmniOut (Managed Package).
-
View Salesforce language codes. See Translations (Salesforce documentation).
-
After adding your multi-language Omniscript to OmniOut, in the VSCode command line, enter this command, and replace LANGCODE with a Salesforce language code:
npm run customlabels LANGCODE -
View these two generated files:
LANGCODE.translations.js: contains all of the custom labels, both user-defined and out-of-the-box, in a single file. The language code replaces the LANGCODE property used in this example file name.
translations.js: contains the exports of all different translations for all of the custom labels.
-
In each LANGCODE.translations.js file, add the translated labels for that
language.
The translated labels aren't downloaded as part of the npm command.
For example, a fr.translations.js file has text for these two labels in English.
export const FR = { "OmniStepValidationError": "Please fix all the fields with errors.", "OmniValidationBadInput": "Enter a valid value.", ... }In this example, the English text is manually replaced with the French labels.
export const FR = { "OmniStepValidationError": "Veuillez corriger tous les champs contenant des erreurs.", "OmniValidationBadInput": "Entrez une valeur valide.", ... } -
In translations.js, uncomment export lines to include them
when the Omniscript is running.
export * from "./es.translations.js"; -
Pass the language code using a combination of these two options:
Note
If both options are present, the component tag property overrides the URL parameter.
Language Code Option
Description
Example
Component Tag Property
Passes the language code in the Omniscript's component tag as a prefill property.
<my-omniscript prefill='\{"LanguageCode":"iw"}'> </my-omniscript>URL Parameter
Append the LanguageCode parameter to your URL endpoint and enter a Salesforce language code.
localhost:4002/myOmniScript?LanguageCode=en_US - (Optional) In the Omniscript component tag, add the run-mode="localScriptDef" attribute to force the Omniscript to use the locally defined custom labels. If run-mode isn’t present, a connection is made to retrieve the custom labels from Salesforce.
- (Optional) If you’re using run-mode="localScriptDef" in your Omniscript component tag, you must define custom translations for each language manually.
- (Optional) Test the multi-language Omniscript In the command line:
What’s next: Run OmniOut in Development Mode (Managed Package).