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>
Static Public Member Functions | |
static icu::message2::FormatterFactory * | CreateFormatterFactory () |
static icu::message2::SelectorFactory * | CreateSelectorFactory () |
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("inflection"), MF2Factory::CreateFormatterFactory(), errorCode) .adoptSelector(FunctionName("inflection"), MF2Factory::CreateSelectorFactory(), errorCode) .build(); UParseError pe; auto mf1 = icu::message2::MessageFormatter::Builder(errorCode) .setFunctionRegistry(customRegistry) .setLocale(Locale::forLanguageTag("es-MX", errorCode)) .setPattern("Location is {$name :inflection 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 :inflection \ feature=gender} \ .local $number = {$name :inflection \ 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 58 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.