A full featured localization system, from Unicode.
MessageFormat 2 is a Unicode standard for localizable dynamic message strings, designed to make it simple to create natural sounding localized messages.
MessageFormat 2 messages can contain variables, which are replaced with values at runtime.
Variables can be moved around in the message freely, allowing translations even to languages where sentence structure doesn't match the source.
Your name is {$name}.
let name = "Alice"
Markup tags can be included in messages, allowing safe rich text formatting in translations.
MessageFormat 2 doesn't assign meaning to markup, giving full control over it's meaning and rendering to the developer.
This is {#bold}important{/bold}.
MessageFormat 2 makes it simple to format numbers, dates, and times in a locale-appropriate way within messages.
It is {$timestamp :time}.
MessageFormat 2 supports pluralization, allowing messages to adapt to the number of items, even in languages with complex plural rules.
Pluralization rules from ECMA-402's Intl.PluralRules are used to match the correct plural form.
.input {$count :number}
.match $count
0 {{ No items. }}
one {{ 1 item. }}
* {{ {$count} items. }}
let count = 3
MessageFormat 2 allows developers to define custom functions to handle complex formatting and matcher needs.
MessageFormat 2 is developed at Unicode, and is built directly into ICU4C, ICU4J, and soon, ECMA-402 (JavaScript's internationalization library).
MessageFormat 2 messages are designed to be easy to translate, with clear markers for variables and formatting, requiring minimal training.