Message Attrib Select Formatter
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 selectedContent copied to clipboard
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}}.Content copied to clipboard
Usage:
FORGOTTEN_BAG( PETER, 1, "one")
-> Peter has forgotten his bag.
FORGOTTEN_BAG( MARY, 2, "few")
-> Mary has forgotten her 2 bags.Content copied to clipboard
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-genderContent copied to clipboard
e.g.
subjects_en.properties
peter=male
mary=femaleContent copied to clipboard
Properties
Functions
Link copied to clipboard
open override fun format(result: StringBuilder, value: Any?, typeId: CharSequence, style: StylePart?, parameters: MessageParameters, locale: Locale, context: MessageFormatContext)
Link copied to clipboard
fun formatAttribute(result: StringBuilder, attrName: CharSequence?, value: Any?, style: StylePart?, parameters: MessageParameters, locale: Locale, context: MessageFormatContext)