Type Alias: MessagePart
MessagePart =
string| {name:string;type:"argument"; } | {name:string;style?:string;type:"number"; } | {name:string;style?:string;type:"date"|"time"; } | {name:string;offset:number;options:Record<string,MessagePart[]>;type:"plural"|"selectordinal"; } | {name:string;options:Record<string,MessagePart[]>;type:"select"; } | {type:"pound"; }
A part of a message parsed by parseMessage: a literal text (a string, its quoting already removed), a plain argument ({name}), a number argument ({n, number, percent}), a date or time argument ({at, date, short}), a choice (plural, selectordinal, select), or the # of a plural (its number).
Union Members
string
Type Literal
{ name: string; type: "argument"; }
name
name:
string
The name of the argument.
type
type:
"argument"
A plain argument, {name}: a number formatted in the language, a Date as a date, anything else as a string.
Type Literal
{ name: string; style?: string; type: "number"; }
name
name:
string
The name of the argument.
style?
optionalstyle?:string
The style: integer, percent, currency or currency/XXX (an ISO 4217 code); absent for a plain number.
type
type:
"number"
A number argument, {name, number} or {name, number, style}.
Type Literal
{ name: string; style?: string; type: "date" | "time"; }
name
name:
string
The name of the argument.
style?
optionalstyle?:string
The style: short, medium, long or full; absent for medium.
type
type:
"date"|"time"
A date argument ({name, date, style}) or a time argument ({name, time, style}).
Type Literal
{ name: string; offset: number; options: Record<string, MessagePart[]>; type: "plural" | "selectordinal"; }
name
name:
string
The name of the argument.
offset
offset:
number
The offset: of the choice, subtracted from the number before its plural rule and its #; 0 without it.
options
options:
Record<string,MessagePart[]>
The messages by selector: =0 (an exact value, matched before the offset), a plural category of the language (zero, one, two, few, many), and the required other.
type
type:
"plural"|"selectordinal"
A cardinal (plural) or ordinal (selectordinal) choice on a number argument.
Type Literal
{ name: string; options: Record<string, MessagePart[]>; type: "select"; }
name
name:
string
The name of the argument.
options
options:
Record<string,MessagePart[]>
The messages by value of the argument, and the required other.
type
type:
"select"
A choice on the string value of an argument, {name, select, admin {...} other {...}}.
Type Literal
{ type: "pound"; }
type
type:
"pound"
The # of a plural: the number of the closest enclosing plural or selectordinal (minus its offset), formatted in the language.