Configure Multi-Language in OmniOut for Omniscripts (Managed Package)

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.

Managed Package app icon 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

  1. Create a multi-language Omniscript. See Create Multi-Language Omniscripts (Managed Package).

  2. Add your multi-language Omniscript to an OmniOut LWC. See Add an Omniscript Lightning Web Component to OmniOut (Managed Package).

  3. View Salesforce language codes. See Translations (Salesforce documentation).

  1. 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
                   
  2. 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.

  3. 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.",
       ...
    }
  4. In translations.js, uncomment export lines to include them when the Omniscript is running.
    export * from "./es.translations.js";
  5. Pass the language code using a combination of these two options:
    Note
    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
                                  
  6. (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.
  7. (Optional) If you’re using run-mode="localScriptDef" in your Omniscript component tag, you must define custom translations for each language manually.

    To define your custom labels:

    1. In OmniOut, select a LANGCODE.translations.js file.

    2. In your file, locate a key-value pair, and in the value field, enter the translation for that custom label. Repeat this process for each custom label.

      export const es = {    
          "New": "Nuevo"
      }
  8. (Optional) Test the multi-language Omniscript In the command line:
    1. In the command line, enter and run the command npm run watch.

    2. Click the localhost link that appears in the command line.

    3. In your browser, edit the URL to include a language code.

      localhost:4002/myOmniScript?LanguageCode=en_US