Formatter
No summary available
import { Formatter } from "@schukai/monster/source/i18n/formatter.mjs";Introduction
I18n Formatter extends the text formatter to resolve translation keys. It wraps translation keys with a special marker and uses the configured Translations instance to return localized strings.
Basic Usage
import { Formatter } from "@schukai/monster/source/i18n/formatter.mjs";
import { Translations } from "@schukai/monster/source/i18n/translations.mjs";
const translations = new Translations("en");
translations.setText("welcome", "Welcome back");
const formatter = new Formatter({}, translations);
formatter.format("i18n{welcome}");
Parameters
You can forward parameters to the translation using the same :: syntax as the text formatter.
formatter.format("i18n{price_label::currency=EUR}");
Exported
FormatterDerived from
TextFormatterOptions
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 TextFormatter.
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 TextFormatter.
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 TextFormatter.
Constructor
constructor(object,translation,options)object{object}: objecttranslation{translations}: translationoptions{object}: [options]
{TypeError}value is not an object
${ and }Static methods
[instanceSymbol]()3.27.0- {symbol}
instanceof operator.Other methods
format(text)text{string}: text
- {string}
{TypeError}value is not a string{Error}too deep nesting{Error}key not found{Error}the closing marker is missing
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.