MessageAttribSelectFormatter

Select a text value based on the named attribute value of the parameter.

Format:

{ PARAMETER_NUMBER, attr:NAME, VALUE1 {TEXT1} VALUE2 VALUE3 {TEXT2} /VALUE_REGEX/ {TEXT_REGEX} other {OTHERWISE_TEXT}}
- NAME
    Name of the attribute
- VALUE
    If a value matches the value of the attribute, the corresponding text (TEXT*) is selected

The rest is similar to the select-pattern.

Example:

{0} has forgotten {0, attr:gender, female {her} other {his} } {2, select, one {bag} other {{1} bags}}.

Usage:

FORGOTTEN_BAG( PETER, 1, "one")
-> Peter has forgotten his bag.
FORGOTTEN_BAG( MARY, 2, "few")
-> Mary has forgotten her 2 bags.

For files storing the attribute, the name of the attribute is appended as an extension after the locale tag via “-x-attr-NAME“. E.g. for the attribute “gender”:

names_de_DE_saxiona-x-attr-gender
names_de_DE-x-attr-gender
names_de-x-attr-gender
names_en-x-attr-gender
names_fr_FR-x-attr-gender

e.g.

subjects_en.properties

peter=male
mary=female

Properties

Link copied to clipboard
open override val typeId: String

ID of the type of the formatter

Link copied to clipboard
open override val typeIdIsPrefix: Boolean

True if typeId is just a prefix for the type.

Functions

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

Formats the given value and writes is to result.

Link copied to clipboard
fun formatAttribute(result: StringBuilder, attrName: CharSequence?, value: Any?, style: StylePart?, parameters: MessageParameters, locale: Locale, context: MessageFormatContext)