MessagePluralFormatter

abstract class MessagePluralFormatter : MessageValueFormatter

It is like a normal select-pattern (#36), but instead of using the number value of the parameter directly, the number is passed to a plural-provider that returns the plural typed of the number.

Predefined return values of the gender-provider zero one two few many other

The plural-provider may also return other values, for currently unconsidered cases.

The are two different plural rule types cardinals ordinals

The default plural provider be based on the Plural Rules(

  • https://cldr.unicode.org/index/cldr-spec/plural-rules) of the Unicode CLDR. They have a large collection of rules(

  • https://www.unicode.org/cldr/charts/43/supplemental/language_plural_rules.html) for almost all language. They also provide JSON files in a special format(

  • http://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules) for cardinals(

  • https://raw.githubusercontent.com/unicode-org/cldr-json/master/cldr-json/cldr-core/supplemental/plurals.json) and ordinals.

For cardinals the “plural” key is used in the pattern. For ordinals the “ordinal” key is used.

Example “plural”:

COUNT_BAGS =  There {0, plural, one {is} other {are} } {0} {0, plural, one {bag} other {bags}}.

COUNT_BAGS(1) -> There is 1 bag.
COUNT_BAGS(2) -> There are 2 bags.

Example “ordinal”:

METING_NUMBER  = This is the {0}{0, ordinal, one {st} two {nd} few {rd} other {th} } meeting.

METING_NUMBER(1) -> This is the 1st meeting.
METING_NUMBER(4) -> This is the 4th meeting.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
abstract val typeId: String
Link copied to clipboard

Functions

Link copied to clipboard
open override fun format(result: StringBuilder, value: Any?, typeId: CharSequence, style: StylePart?, parameters: MessageParameters, locale: Locale, context: MessageFormatContext)