Let the platform do the work

Language

Overview

The language library, located in ./sidecar/src/core/language.js, is used to manage the user's display language as well as fetch labels and lists. For more information on customizing languages, please visit the language framework documentation.

Methods

app.lang.get(key, module, context)

The app.lang.get(key, module, context) method fetches a string for a given key. The method searches the module strings first and then falls back to the app strings. If the label is a template, it will be compiled and executed with the given context.

Parameters

Name Required Description
key yes The key of the string to retrieve
module no The Sugar module that the label belongs to
context no Template context

Example

app.lang.get('LBL_NAME', 'Accounts');

app.lang.getAppString(key)

The app.lang.getAppString(key) method retrieves an application string for a given key.

Parameters

Name Required Description
key yes The key of the string to retrieve

Example

app.lang.getAppString('LBL_MODULE');

app.lang.getAppListStrings(key)

The app.lang.getAppListStrings(key) method retrieves an application list string or object.

Parameters

Name Required Description
key yes The key of the string to retrieve

Example

app.lang.getAppListStrings('sales_stage_dom');

app.lang.getModuleSingular(moduleKey)

The app.lang.getModuleSingular(moduleKey) method retrieves an application list string or object.

Parameters

Name Required Description
moduleKey yes The module key of the singular module label to retrieve

Example

app.lang.getModuleSingular("Accounts");

app.lang.getLanguage()

The app.lang.getLanguage() method retrieves the current user's language key.

Example

app.lang.getLanguage();

app.lang.updateLanguage(languageKey)

The app.lang.updateLanguage(languageKey) method updates the current user's language key.

Parameters

Name Required Description
languageKey yes Language key of the language to set for the user

Example

app.lang.updateLanguage('en_us');

Testing in Console

To test out the language library, you can trigger actions in your browsers developer tools by using the global Apps variable as shown below:

App.lang.getAppListStrings('sales_stage_dom');

Topics