Message Select Formatter
Select a text value based on the value of the parameter.
Format:
{ PARAMETER_NUMBER, select, VALUE1 {TEXT1} VALUE2 VALUE3 {TEXT2} /VALUE_REGEX/ {TEXT3} other {OTHERWISE_TEXT} }PARAMETER_NUMBER:Number of the parameter which value is matched against the values of the select list
VALUE*:If a values matches the value of the parameter, the corresponding text (TEXT*) is selected
List of several values for the same text can be listed before the next text element
VALUE_REGEXWhen the value is prefixed and suffixed by "/", it is seen as regular repression, e.g.
/([A-Z])\w+/If the regex matches the value of the parameter, the corresponding text (TEXT3) is selected
TEXT*:Text that is returned by the pattern if the value matches the value of the parameter
Texts themselves can also contain patterns. So, the patterns can be nested.
OTHERWISE_TEXTIf none of the values before matched, this text will be selected
If there is no OTHERWISE_TEXT specified and no value matches, an empty string is returned
Values and texts are trimmed (leading and tailing whitespaces are removed)
Example:
{0} has forgotten {1, select, female: her | his } {3, select, one: bag | {2} bags}.Usage:
FORGOTTEN_BAG("Peter", "male", 1, "one")
-> Peter has forgotten his bag.
FORGOTTEN_BAG("Mary", "female", 2, "few")
-> Mary has forgotten her 2 bags.