Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MultiString

An object that contains string translations for multiple languages. Language keys use two-letter codes like: 'en', 'sp', 'de', 'ru', 'fr', 'pr'. When translation for specified language does not exists it defaults to English ('en'). When English does not exists it falls back to the first defined language.

Example

let values = MultiString.fromTuples(
    "en", "Hello World!",
    "ru", "Привет мир!"
);

let value1 = values.get('ru'); // Result: "Привет мир!"
let value2 = values.get('pt'); // Result: "Hello World!"

Hierarchy

  • MultiString

Index

Constructors

constructor

  • Creates a new MultiString object and initializes it with values.

    Parameters

    • Default value map: any = null

      a map with language-text pairs.

    Returns MultiString

Methods

append

  • append(map: any): void
  • Appends a map with language-translation pairs.

    Parameters

    • map: any

      the map with language-translation pairs.

    Returns void

clear

  • clear(): any

get

  • get(language: string): string
  • Gets a string translation by specified language. When language is not found it defaults to English ('en'). When English is not found it takes the first value.

    Parameters

    • language: string

      a language two-symbol code.

    Returns string

    a translation for the specified language or default translation.

getLanguages

  • getLanguages(): string[]
  • Gets all languages stored in this MultiString object,

    Returns string[]

    a list with language codes.

length

  • length(): number
  • Returns the number of translations stored in this MultiString object.

    Returns number

    the number of translations.

put

  • put(language: string, value: any): any
  • Puts a new translation for the specified language.

    Parameters

    • language: string

      a language two-symbol code.

    • value: any

      a new translation for the specified language.

    Returns any

remove

  • remove(language: string): void
  • Removes translation for the specified language.

    Parameters

    • language: string

      a language two-symbol code.

    Returns void

Static fromTuples

  • Creates a new MultiString object from language-translation pairs (tuples).

    see

    fromTuplesArray

    Parameters

    • Rest ...tuples: any[]

      an array that contains language-translation tuples.

    Returns MultiString

    a MultiString Object.

Static fromTuplesArray

  • Creates a new MultiString object from language-translation pairs (tuples) specified as array.

    Parameters

    • tuples: any[]

      an array that contains language-translation tuples.

    Returns MultiString

    a MultiString Object.

Static fromValue

  • Creates a new MultiString object from a value that contains language-translation pairs.

    see

    StringValueMap

    Parameters

    • value: any

      the value to initialize MultiString.

    Returns MultiString

    a MultiString object.

Generated using TypeDoc