Class: MultiLangString

.models. MultiLangString

A class representing a transcription in one or more languages or writing systems.

new MultiLangString( [data] [, options])

Create a new Multi-Language String
Parameters:
Name Type Argument Description
data Object <optional>
The data for this transcription, as a plan Object or Map. See the MultiLangString specification for more information on formatting transcription data.
options Object <optional>
An options object
Properties
Name Type Argument Description
default String <optional>
The default orthography to get and set
Properties:
Name Type Description
default String The default orthography to get and set. This property is not enumerable.
Example
const str = new MultiLangString({
  spa: 'Hola, me llamo Daniel.',
  ipa: 'ola me jamo danjɛl',
}, {
  default: 'spa',
});

str.eng = 'Hello, my name is Daniel.';

console.log(str.spa);     // Hola, me llamo Daniel.
console.log(str.ipa);     // ola me jamo danjɛl
console.log(str.default); // 'spa'

Extends

  • Map

Methods


<static> alias(object, mlsProp, defaultProp)

Adds a new property to the provided object. The new property is an alias for the default orthography of the given MultiLangString property (i.e., a shorthand for `object[mlsProp][object[mlsProp].default]`). The new property will not be configurable or enumerable, only writable.
Parameters:
Name Type Description
object Object The object to add the alias property to
mlsProp String The name of the MultiLangString property whose default orthography you want to alias
defaultProp String The name of the new alias property.
Returns:
Returns the object with the new property added
Type
Object
Example
const phrase = {
  translation: new MultiLangString({
    default: 'eng',
    eng:     'Hello world!',
    spa:     'Hola mundo!',
  }),
};

MultiLangString.alias(phrase, 'translation', 'tln');

console.log(phrase.tln); // 'Hello world!'