[
https://issues.apache.org/jira/browse/SLING-10654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Konrad Windszus closed SLING-10654.
-----------------------------------
> HTL optionally support ICU4j MessageFormat for string formatting
> ----------------------------------------------------------------
>
> Key: SLING-10654
> URL: https://issues.apache.org/jira/browse/SLING-10654
> Project: Sling
> Issue Type: New Feature
> Components: Scripting
> Reporter: Dirk Rudolph
> Assignee: Dirk Rudolph
> Priority: Major
> Fix For: Scripting HTL Engine 1.4.22-1.4.0
>
> Time Spent: 5h 20m
> Remaining Estimate: 0h
>
> The [ICU
> MessageFormat|https://unicode-org.github.io/icu-docs/apidoc/dev/icu4j/com/ibm/icu/text/MessageFormat.html]
> 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|https://github.com/adobe/htl-spec/blob/1.4/SPECIFICATION.md#122-format]
> in {{Strings}}.
> {quote}placeholders (eg: \{0}) in the pattern, triggers string formatting
> {quote}
> 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)