Lexicon

nmodule/js/rc/lex/lex~ Lexicon

new Lexicon(moduleName, data)

Description:
  • A Lexicon is a map of locale specific name/value pairs for a module.

    An instance of a Lexicon can be accessed indirectly by use of the
    module method.

Source:
Example

Access a module's Lexicon

  lexjs.module("js")
       .then(function (lex) {
         console.log("Some text from a lexicon: " + lex.get("dialogs.ok"));
       });
Parameters:
Name Type Description
moduleName String

The name of the Niagara Module this Lexicon relates too.

data Object

An object contained key values pairs for the Lexicon.

Methods

get(obj) → {String}

Description:
  • Return a value from the Lexicon for a given key.

    The argument for this method can be either a String key followed by arguments or an Object Literal.

Source:
Examples

Access a Lexicon value via its key name.

  lexjs.module("js")
       .then(function (lex) {
         console.log(lex.get("dialogs.ok"));
       });
       

Access a Lexicon value via its key name with some formatted parameters.

  lexjs.module("bajaui")
       .then(function (lex) {
          var val = lex.get("fileSearch.scanningFiles", "alpha", "omega"))
          // Prints out: Scanning files (found alpha of omega)...
          console.log(val);
       })); 
       

Provide a default value if the key can't be found and use an Object Literal instead

  lexjs.module("bajaui")
       .then(function (lex) {
         // Use an Object Literal instead of multiple arguments and provide a default value.
         var val = lex.get({
           key: "fileSearch.scanningFiles",
           def: "Return this if the key can't be found in the Lexicon",
           args: ["alpha", "omega"]
         });
         console.log(val);
       });
Parameters:
Name Type Description
obj Object | String

the Object Literal that contains the method's arguments or a String key.

Properties
Name Type Description
key String

the key to look up.

def String

the default value to return if the key can't be found.
By default, this is null.

args Array | String

arguments used for String formatting. If the first parameter
is a String key, this list can just be further arguments for the function.

Returns:

the value for the Lexicon or return def if it can't be found.

Type
String

getModuleName() → {String}

Description:
  • Return the Lexicon's module name.

Source:
Example

Return a Lexicon's module name

  lexjs.module("bajaui")
       .then(function (lex) {
          // Prints out: bajaui
          console.log(lex.getModuleName());
       })); 
Returns:
Type
String

getRaw(obj) → {String}

Description:
  • Return the raw and unescaped value of the key which is not safe to display.

Source:
Since:
  • Niagara 4.8
See:
  • Lexicon.get
Parameters:
Name Type Description
obj Object | String

the Object Literal that contains the method's arguments or a String key.

Properties
Name Type Description
key String

the key to look up.

def String

the default value to return if the key can't be found.
By default, this is null.

args Array | String

arguments used for String formatting. If the first parameter
is a String key, this list can just be further arguments for the function.

Returns:
Type
String

getSafe(obj) → {String}

Description:
  • Return escaped value of the key which is safe to display.

Source:
Since:
  • Niagara 4.8
See:
  • Lexicon.get
Parameters:
Name Type Description
obj Object | String

the Object Literal that contains the method's arguments or a String key.

Properties
Name Type Description
key String

the key to look up.

def String

the default value to return if the key can't be found.
By default, this is null.

args Array | String

arguments used for String formatting. If the first parameter
is a String key, this list can just be further arguments for the function.

Returns:
Type
String