@Deprecated public class MessageFormatter extends Object
MessageFormatter is the next iteration of MessageFormat.
This new version builds on what we learned from using MessageFormat for 20 years
in various environments, either exposed "as is" or as a base for other public APIs.
It is more modular, easier to backport, and provides extension points to add new formatters and selectors without having to modify the specification.
We will be able to add formatters for intervals, relative times, lists, measurement units, people names, and more, and support custom formatters implemented by developers outside of ICU itself, for company or even product specific needs.
MessageFormat 2 will support more complex grammatical features, such as gender, inflections, and tagging parts of the message for style changes or speech.
The reasoning for this effort is shared in the “Why MessageFormat needs a successor” document.
The “MessageFormat 2” project, which develops the new data model, semantics, and syntax, is hosted on GitHub.
The current specification for the syntax and data model can be found here.
This tech preview implements enough of the MessageFormat functions to be useful,
but the final set of functions and the parameters accepted by those functions is not yet finalized.
These are the functions interpreted right now:
datetime |
Similar to the ICU "date" and "time". |
datestyle and timestyleSimilar to argStyle : short | medium | long | full.Same values are accepted, but we can use both in one placeholder, for example {$due :datetime datestyle=full timestyle=long}.
| |
patternSimilar to argStyle = argStyleText.This is bad i18n practice, and will probably be dropped. This is included just to support migration to MessageFormat 2. | |
skeletonSame as argStyle = argSkeletonText.These are the date/time skeletons as supported by SimpleDateFormat.
| |
number |
Similar to the ICU "number". |
skeletonThese are the number skeletons as supported by NumberFormatter. | |
minimumFractionDigitsOnly implemented to be able to pass the unit tests from the ECMA tech preview implementation, which prefers options bags to skeletons. TBD if the final function will support skeletons, option backs, or both. | |
offsetUsed to support plural with an offset. | |
identity | Returns the direct string value of the argument (calling toString()). |
plural |
Similar to the ICU "plural". |
skeletonThese are the number skeletons as supported by NumberFormatter.Can also be indirect, from a local variable of type number (recommended). | |
offsetUsed to support plural with an offset. Can also be indirect, from a local variable of type number (recommended). | |
selectordinal |
Similar to the ICU "selectordinal".For now it accepts the same parameters as "plural", although there is no use case for them. TBD if this will be merged into "plural" (with some kind option) or not. |
select | Literal match, same as the ICU4 "select". |