Translations

No summary available

Import
the javascript logo
import { Translations } from "@schukai/monster/source/i18n/translations.mjs";
Source
the git logo
Package
the npm logo
Since
1.13.0

Exported

Translations, getDocumentTranslations

Derived from

Base

Options

The Options listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the Base.

Option
Type
Default
Description
-/-

Properties

The Properties listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Properties from these parent classes. If you cannot find a specific Properties in this list, we recommend consulting the documentation of the Base.

Methods

The methods listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the Base.

Constructor

constructor(locale)
Parameters
  • locale {locale}: locale

Structural methods

getPluralRuleText(key,count,defaultText)
Parameters
  • key {string}: key
  • count {integer|string}: count
  • defaultText {string|undefined}: defaultText
Returns
  • {string}
A number count can be passed to this method. In addition to a number, one of the keywords can also be passed directly. "zero", "one", "two", "few", "many" and "other". Remember: not every language has all rules. The appropriate text for this number is then selected. If no suitable key is found, defaultText is taken.
getText(key,defaultText)
Parameters
  • key {string}: key
  • defaultText {string|undefined}: defaultText
Returns
  • {string}
Throws
  • {Error} key not found
Fetches a text using the specified key. If no suitable key is found, defaultText is taken.
setText(key,text)
Parameters
  • key {string}: key
  • text {string|object}: text
Returns
  • {Translations}
Throws
  • {TypeError} value is not a string or object
Set a text for a key ``translations.setText("text1", "Make my day!"); // plural rules translations.setText("text6", { "zero": "There are no files on Disk.", "one": "There is one file on Disk.", "other": "There are files on Disk." "default": "There are files on Disk." });``

Static methods

[instanceSymbol]()3.27.0
Returns
  • {symbol}
This method is called by the instanceof operator.

Other methods

assignTranslations(translations)
Parameters
  • translations {object}: translations
Returns
  • {Translations}
This method can be used to transfer overlays from an object. The keys are transferred, and the values are entered as text. The values can either be character strings or, in the case of texts with plural forms, objects. The plural forms must be stored as text via a standard key "zero", "one", "two", "few", "many" and "other". Additionally, the key default can be specified, which will be used if no other key fits. In some languages, like for example in German, there is no own more number at the value 0. In these languages, the function applies additionally zero. ``translations.assignTranslations({ "text1": "Make my day!", "text2": "I'll be back!", "text6": { "zero": "There are no files on Disk.", "one": "There is one file on Disk.", "other": "There are files on Disk." "default": "There are files on Disk." });``

Events

This component does not fire any public events. It may fire events that are inherited from its parent classes.

The current width of the area is too small to display the content correctly.