Class: MultiLangString

models~ MultiLangString

A class representing a Multi-Language Text / String, as a JavaScript Map Object. See the DLx Data Format for information about formatting Multi-Language Strings.


new MultiLangString( [data])

Create a new MultiLangString

Parameters:
Name Type Argument Default Description
data Map | Object | String <optional>
{}

The data to use for this MultiLangString, as either a Map, an Object, or a String. If a String is provided, it is assumed to be English.

Example
const translation = new MultiLangString({
  spa: 'Hola, me llamo Daniel.',
  eng: 'Hello, my name is Daniel.',
});

console.log(translation.get(`spa`)); // Hola, me llamo Daniel.

Extends

  • Map

Methods


<inner> validateLanguageTag(input)

Validates a language tag. Throws a type error if the input is not a valid IETF language tag.

Parameters:
Name Type Description
input Any

The input to validate


<inner> validateString(input)

Validates a String for MultiLangStrings. Throws a type error if the input is not a String.

Parameters:
Name Type Description
input Any

The input to validate