MessageFormat 2
Format adapter@parlajs/format-mf2, built into @parlajs/compiler: a namespace
sets format: 'mf2'.
{ "items": ".input {$count :number}\n.match $count\n0 {{Your cart is empty}}\none {{{$count} item}}\n* {{{$count} items}}"}| MF2 | |
|---|---|
{$name} |
Placeholder |
.input {$n :number} .match $n |
Plural; several selectors too |
:number select=ordinal |
Ordinal |
.local $rest = {$n :offset subtract=1} |
A number to format or select by |
:string |
Select, typed per branch |
:number, :integer, :currency, :percent, :unit |
Numbers |
:date, :time, :datetime |
Dates: fields, length, precision, or style=full |
.input, .local |
Declarations |
{#link}…{/link}, {#br/} |
Rich text |
:number, :integer and :percent select by the number they write: 1.0 is plural in English.
The spec: messageformat.unicode.org. The same messages in ICU: Plurals and selects.