MessageFormat.(constructor)

Create a new MessageFormat compiler

Signature:

constructor(locale: string | PluralFunction | Array<string | PluralFunction> | null, options?: MessageFormatOptions<ReturnType>);

Parameters

Parameter Type Description
locale string | PluralFunction | Array<string | PluralFunction> | null The locale or locales supported by this MessageFormat instance.
options MessageFormatOptions<ReturnType> (Optional) Options for this instance

Remarks

If given multiple valid locales, the first will be the default. If locale is empty, it will fall back to MessageFormat.defaultLocale.

String locale values will be matched to plural categorisation functions provided by the Unicode CLDR. If defining your own instead, use named functions, optionally providing them with the properties: cardinals: string[], ordinals: string[], and module: string (to import the formatter as a runtime dependency, rather than inlining its source).

If locale has the special value '*', it will match **all** available locales. This may be useful if you want your messages to be completely determined by your data, but may provide surprising results if your input message object includes any 2-3 character keys that are not locale identifiers.