Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The ICU MessageFormat provides a rich set of features compared to the currently implemented, simple placeholder replacement. In particular I am referring to the support for plural rules. Plural forms for words in combination with numbers are not as simple in all language as they are in English (or German), for example consider the following format {0} result(s)
Language | One | Few | Many |
---|---|---|---|
English | 1 result | 3 results | 15 results |
German | 1 Ergebnis | 3 Ergebnisse | 15 Ergebnisse |
Czech | 1 výsledek | 3 výsledky | 15 výsledků |
With the ICU Message Format the above format could be modified according to a locale to support this
Locale | Format |
---|---|
en | {0,plural, one {# result} other {# results}} |
de | {0,plural, one {# Ergebnis} other {# Ergebnisse}} |
cs | {0,plural, one {# výsledek} few {# výsledky} other {# výsledků}} |
According to the HTL specification the format option allows to replace placeholders in Strings.
placeholders (eg: {0}) in the pattern, triggers string formatting
It does not define a specific definition of a placeholder and simply refers to {0} as an example. The support of complex placeholders as described above should be a valid implementation detail.
However, with only regular placeholders the overhead of parsing the format as ICU MessageFormat comes with a performance penalty. So it must only be used if the format contains at least one complex placeholder, for example identified by {\d+,[^}]+}. The support can be implemented completely optional, depending on the existence of icu4j at runtime.