MessageFormat class

MessageFormat grammar:

message := messageText (argument messageText)*
argument := simpleArg | pluralArg | selectArg

simpleArg := "#" | "{" argNameOrNumber "}"
pluralArg := "{" argNameOrNumber "," "plural" "," pluralStyle "}"
selectArg := "{" argNameOrNumber "," "select" "," selectStyle "}"

argNameOrNumber := identifier | number

pluralStyle := [offsetValue] (pluralSelector "{" message "}")+
offsetValue := "offset:" number
pluralSelector := explicitValue | pluralKeyword
explicitValue := "=" number  // adjacent, no white space in between
pluralKeyword := "zero" | "one" | "two" | "few" | "many" | "other"

selectStyle := (selectSelector "{" message "}")+
selectSelector := keyword

identifier := [^[[:Pattern_Syntax:][:Pattern_White_Space:]]]+
number := "0" | ("1".."9" ("0".."9")*)

NOTE: "#" has special meaning only inside a plural block. It is "connected" to the argument of the plural, but the value of # is the value of the plural argument minus the offset.

Quoting/Escaping: if syntax characters occur in the text portions, then they need to be quoted by enclosing the syntax in pairs of ASCII apostrophes.

A pair of ASCII apostrophes always represents one ASCII apostrophe, similar to %% in printf representing one %, although this rule still applies inside quoted text.

("This '{isn''t}' obvious" → "This {isn't} obvious")

An ASCII apostrophe only starts quoted text if it immediately precedes a character that requires quoting (that is, "only where needed"), and works the same in nested messages as on the top level of the pattern.

Recommendation: Use the real apostrophe (single quote) character ’ (U+2019) for human-readable text, and use the ASCII apostrophe ' (U+0027) only in program syntax, like escaping.

This is a subset of the ICU MessageFormat syntax:

Message example:

I see {NUM_PEOPLE, plural, offset:1
        =0 {no one at all}
        =1 {{WHO}}
        one {{WHO} and one other person}
        other {{WHO} and # other people}}
in {PLACE}.

Calling format({'NUM_PEOPLE': 2, 'WHO': 'Mark', 'PLACE': 'Athens'}) would produce "I see Mark and one other person in Athens." as output.

Calling format({'NUM_PEOPLE': 5, 'WHO': 'Mark', 'PLACE': 'Athens'}) would produce "I see Mark and one 4 other people in Athens." as output. Notice how the "#" is the value of NUM_PEOPLE - 1 (the offset).

Another important thing to notice is the existence of both "=1" and "one". You should think of the plural keywords as names for "buckets of numbers" which have only a loose connection to the numerical value.

In English there is no difference, but for example in Russian all the numbers that end with "1" but not with "11" are mapped to "one"

For more information please visit: and


MessageFormat(String pattern, {String locale: 'en'})
Create a MessageFormat for the ICU message string pattern. It does parameter substitutions in a locale-aware way. The syntax is similar to the one used by ICU and is described in the grammar above.


hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


format([Map<String, Object> namedParameters]) String
Returns a formatted message, treating '#' as a special placeholder. [...]
formatIgnoringPound([Map<String, Object> namedParameters]) String
Returns a formatted message, treating '#' as literal character. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
Returns a string representation of this object.


operator ==(Object other) bool
The equality operator. [...]