MessageFormatClassic
The 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.
Constructors
new MessageFormatClassic()
new MessageFormatClassic(): MessageFormatClassic
Returns
Methods
format()
staticformat(pattern:string, args:Map<string, string | number | Date>):string | null
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. Formatted message on success, null on failure.
Returns
string | null
formatPositional()
staticformatPositional(pattern:string, args?:(string | number | Date)[]):string | null
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 Formatted message on success, null on failure.
Returns
string | null
formatPositionalWithLocale()
staticformatPositionalWithLocale(pattern:string, locale:string | null, args?:(string | number | Date)[]):string | null
Formats the specified pattern with numbered arguments in the specified locale.
Parameters
pattern
string
A classic message format pattern.
locale
string | null
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 Formatted message on success, null on failure.
Returns
string | null
formatWithLocale()
staticformatWithLocale(pattern:string, locale:string | null, args:Map<string, string | number | Date>):string | null
Formats the specified pattern with named arguments in the specified locale.
Parameters
pattern
string
A classic message format pattern.
locale
string | null
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. Formatted message on success, null on failure.
Returns
string | null
getMajorVersion()
staticgetMajorVersion():number
Gets the major version number. Major version number.
Returns
number
getMinorVersion()
staticgetMinorVersion():number
Gets the minor version number. Minor version number.
Returns
number
getPatchVersion()
staticgetPatchVersion():number
Gets the patch version number. Patch version number.
Returns
number
Last updated: Jul 22, 2026

