|
Inflection
Morphology Inflection
|
The MF2Factory provide factory method to create custom formatter and selector factory to work with icu::message2 library. The intend usage is to creat icu::message2::FormatterFactory or icu::message2::SelectorFactory and use it with icu::message2::MFFunctionRegistry::Builder to construct a custom function registry to build MessageFormatter with MessageFormatter::Builder.
More...
#include <MF2Factory.hpp>
Public Types | |
| enum class | OutputMode { PLAIN , SSML } |
Static Public Member Functions | |
| static icu::message2::FormatterFactory * | createInflectFormatterFactory (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::SelectorFactory * | createInflectSelectorFactory () |
| static icu::message2::FormatterFactory * | createNumeralFormatterFactory (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::FormatterFactory * | createQuantifyFormatterFactory (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::FormatterFactory * | createListFormatterFactory (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::FormatterFactory * | createPronounFormatterFactory (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::SelectorFactory * | createPronounSelectorFactory () |
The MF2Factory provide factory method to create custom formatter and selector factory to work with icu::message2 library. The intend usage is to creat icu::message2::FormatterFactory or icu::message2::SelectorFactory and use it with icu::message2::MFFunctionRegistry::Builder to construct a custom function registry to build MessageFormatter with MessageFormatter::Builder.
For example:
auto customRegistry = icu::message2::MFFunctionRegistry::Builder(errorCode)
.adoptFormatter(FunctionName("inflect"),
MF2Factory::createInflectFormatterFactory(), errorCode)
.adoptSelector(FunctionName("inflect"),
MF2Factory::createInflectSelectorFactory(), errorCode)
.build();
UParseError pe;
auto mf1 = icu::message2::MessageFormatter::Builder(errorCode)
.setFunctionRegistry(customRegistry)
.setLocale(Locale::forLanguageTag("es-MX", errorCode))
.setPattern("Location is {$name :inflect hello=world \
definiteness=definite number=plural \
gender=feminine}",
pe, errorCode)
.build(errorCode);
auto mf2 = icu::message2::MessageFormatter::Builder(errorCode)
.setFunctionRegistry(customRegistry)
.setLocale(Locale::forLanguageTag("es-MX", errorCode))
.setPattern(".local $gender = {$name :inflect \
feature=gender} \
.local $number = {$name :inflect \
feature=number} \
.match $gender $number \
feminine singular {{Feminine Singular {$name}}}\
masculine singular {{Masculine Singular {$name}}}\
* * {{other {$name} }}\n",
pe, errorCode)
.build(errorCode);
Definition at line 57 of file MF2Factory.hpp.
|
strong |
Controls how formatters serialize their result: PLAIN emits the print form only; SSML emits Speech Synthesis Markup Language (SSML) markup — a <sub alias="..."> element when print differs from speak.
Definition at line 66 of file MF2Factory.hpp.
|
static |
Create an implementation of icu::message2::FormatterFactory*, based on the infleciton library, which can be passed to icu::messsage2::MFFunctionRegistry::Builder::adoptFormatter to register a custom formatter factory.
|
static |
Create an implementation of icu::message2::SelectorFactory*, based on the infleciton library, which can be passed to icu::messsage2::MFFunctionRegistry::Builder::adoptSelector to register a custom selector factory.
|
static |
Create a FormatterFactory for the :list function (array → plain/and/or list).
|
static |
Create an implementation of icu::message2::FormatterFactory* for the :numeral function (number formatting), based on the inflection library, which can be passed to icu::messsage2::MFFunctionRegistry::Builder::adoptFormatter to register a custom formatter factory.
|
static |
Create a FormatterFactory for the :pronoun function.
|
static |
Create a SelectorFactory for the :pronoun function.
|
static |
Create a FormatterFactory for the :quantify function (count + unit agreement).