MessageFormatClassic API adopts the classic
ICU MessageFormat
patterns for formatting messages.
The MessageFormatClassic API supports both named-argument style and numbered-argument style in patterns.
Use the named-argument style to improve readability for developers and translators by providing descriptively
named arguments. In addition, that can better infer what kind of values go into the arguments in a pattern.
Examples
Constructors
new MessageFormatClassic()
new MessageFormatClassic():MessageFormatClassic
Returns
MessageFormatClassic
Methods
format()
static format(pattern, args): null | string
Formats the specified pattern with named arguments in the default locale.
Parameters
pattern
string
A classic message format pattern.
args
Map<string, string | number | Date>
Map of argument names to their values.
Returns
null | string
Formatted message on success, null on failure.
formatPositional()
static formatPositional(pattern, …args): null | string
Formats the specified pattern with numbered arguments in the default locale.
Parameters
pattern
string
A classic message format pattern.
args
…(string | number | Date)[]
Array of argument values
Returns
null | string
Formatted message on success, null on failure.
formatPositionalWithLocale()
static formatPositionalWithLocale(pattern, locale, …args): null | string
Formats the specified pattern with numbered arguments in the specified locale.
Parameters
pattern
string
A classic message format pattern.
locale
A BCP-47 locale string. If this parameter is null or an empty string, the default locale is used.args
…(string | number | Date)[]
Array of argument values
Returns
null | string
Formatted message on success, null on failure.
formatWithLocale()
static formatWithLocale(pattern, locale, args): null | string
Formats the specified pattern with named arguments in the specified locale.
Parameters
pattern
string
A classic message format pattern.
locale
A BCP-47 locale string. If this parameter is null or an empty string, the default locale is used.args
Map<string, string | number | Date>
Map of argument names to their values.
Returns
null | string
Formatted message on success, null on failure.
getMajorVersion()
static getMajorVersion(): number
Gets the major version number.
Returns
number
Major version number.
getMinorVersion()
static getMinorVersion(): number
Gets the minor version number.
Returns
number
Minor version number.
getPatchVersion()
static getPatchVersion(): number
Gets the patch version number.
Returns
number
Patch version number.

