Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/inflection/message2/MF2Factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
* <blockquote>
* <pre>
* auto customRegistry = icu::message2::MFFunctionRegistry::Builder(errorCode)
* .adoptFormatter(FunctionName("inflect"),
* .adoptFormatter(FunctionName("i:inflect"),
* MF2Factory::createInflectFormatterFactory(), errorCode)
* .adoptSelector(FunctionName("inflect"),
* .adoptSelector(FunctionName("i: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 \
* .setPattern("Location is {$name :i:inflect hello=world \
* definiteness=definite number=plural \
* gender=feminine}",
* pe, errorCode)
Expand All @@ -40,9 +40,9 @@
* auto mf2 = icu::message2::MessageFormatter::Builder(errorCode)
* .setFunctionRegistry(customRegistry)
* .setLocale(Locale::forLanguageTag("es-MX", errorCode))
* .setPattern(".local $gender = {$name :inflect \
* .setPattern(".local $gender = {$name :i:inflect \
* feature=gender} \
* .local $number = {$name :inflect \
* .local $number = {$name :i:inflect \
* feature=number} \
* .match $gender $number \
* feminine singular {{Feminine Singular {$name}}}\
Expand Down Expand Up @@ -83,22 +83,22 @@ class INFLECTION_CLASS_API inflection::message2::MF2Factory {

/**
* Create an implementation of icu::message2::FormatterFactory* for the
* :numeral function (number formatting), based on the inflection library,
* :i: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 icu::message2::FormatterFactory* createNumeralFormatterFactory(OutputMode mode = OutputMode::PLAIN);

/** Create a FormatterFactory for the :quantify function (count + unit agreement). */
/** Create a FormatterFactory for the :i:quantify function (count + unit agreement). */
static icu::message2::FormatterFactory* createQuantifyFormatterFactory(OutputMode mode = OutputMode::PLAIN);

/** Create a FormatterFactory for the :list function (array → plain/and/or list). */
/** Create a FormatterFactory for the :i:list function (array → plain/and/or list). */
static icu::message2::FormatterFactory* createListFormatterFactory(OutputMode mode = OutputMode::PLAIN);

/** Create a FormatterFactory for the :pronoun function. */
/** Create a FormatterFactory for the :i:pronoun function. */
static icu::message2::FormatterFactory* createPronounFormatterFactory(OutputMode mode = OutputMode::PLAIN);

/** Create a SelectorFactory for the :pronoun function. */
/** Create a SelectorFactory for the :i:pronoun function. */
static icu::message2::SelectorFactory* createPronounSelectorFactory();
};
6 changes: 3 additions & 3 deletions test/resources/inflection/message2/de_DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<params>
<param name="name" type="String"><value>Bank</value></param>
</params>
<source>.local $defArticleInPreposition = {$name :inflect number=singular case=accusative to=defArticleInPreposition} .match $defArticleInPreposition
<source>.local $defArticleInPreposition = {$name :i:inflect number=singular case=accusative to=defArticleInPreposition} .match $defArticleInPreposition
|in die| {{The defArticleInPreposition of '{$name}' is 'in die'.}}
* {{The defArticleInPreposition of '{$name}' is unexpectedly '$defArticleInPreposition'.}}
</source>
Expand All @@ -18,7 +18,7 @@
<params>
<param name="name" type="String"><value>Fundort</value></param>
</params>
<source>.local $withDefArticleInPreposition = {$name :inflect number=singular case=dative to=withDefArticleInPreposition} .match $withDefArticleInPreposition
<source>.local $withDefArticleInPreposition = {$name :i:inflect number=singular case=dative to=withDefArticleInPreposition} .match $withDefArticleInPreposition
|im Fundort| {{The withDefArticleInPreposition of '{$name}' is 'im Fundort'.}}
* {{The withDefArticleInPreposition of '{$name}' is something else.}}
</source>
Expand All @@ -28,7 +28,7 @@
<params>
<param name="name" type="String"><value>Bank</value></param>
</params>
<source>The defArticleInPreposition is {$name :inflect number=singular case=accusative to=defArticleInPreposition}.</source>
<source>The defArticleInPreposition is {$name :i:inflect number=singular case=accusative to=defArticleInPreposition}.</source>
<print>The defArticleInPreposition is in die.</print>
</test>
</message2test>
48 changes: 24 additions & 24 deletions test/resources/inflection/message2/en_US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
<params>
<param name="object" type="String"><value>lights</value></param>
</params>
<source>The {$object} {is :inflect number=$object} on.</source>
<source>The {$object} {is :i:inflect number=$object} on.</source>
<print>The lights are on.</print>
</test>
<test>
<params>
<param name="object" type="String"><value>lights</value></param>
</params>
<source>{$object :inflect definiteness=definite} {is :inflect number=$object} on.</source>
<source>{$object :i:inflect definiteness=definite} {is :i:inflect number=$object} on.</source>
<print>the lights are on.</print>
</test>
<test>
<params>
<param name="object" type="String"><value>light</value></param>
</params>
<source>.local $num = {$object :inflect to=number} .match $num
<source>.local $num = {$object :i:inflect to=number} .match $num
plural {{The {$object} are on}}
* {{The {$object} is on}}
</source>
Expand All @@ -32,7 +32,7 @@ plural {{The {$object} are on}}
<params>
<param name="object" type="String"><value>lights</value></param>
</params>
<source>.local $num = {$object :inflect to=number} .match $num
<source>.local $num = {$object :i:inflect to=number} .match $num
plural {{The {$object} are on}}
* {{The {$object} is on}}
</source>
Expand All @@ -42,7 +42,7 @@ plural {{The {$object} are on}}
<params>
<param name="object" type="String"><value>lights on the front porch</value></param>
</params>
<source>.local $num = {$object :inflect to=number} .match $num
<source>.local $num = {$object :i:inflect to=number} .match $num
plural {{The {$object} are on}}
* {{The {$object} is on}}
</source>
Expand All @@ -52,7 +52,7 @@ plural {{The {$object} are on}}
<params>
<param name="object" type="String"><value>light on the front porch</value></param>
</params>
<source>.local $num = {$object :inflect to=number} .match $num
<source>.local $num = {$object :i:inflect to=number} .match $num
plural {{The {$object} are on}}
* {{The {$object} is on}}
</source>
Expand All @@ -62,28 +62,28 @@ plural {{The {$object} are on}}
<params>
<param name="relationship" type="String"><value>brother</value></param>
</params>
<source>I didn't find {$relationship :inflect definiteness=indefinite} in your contacts. What is your {$relationship :inflect case=genitive} name?</source>
<source>I didn't find {$relationship :i:inflect definiteness=indefinite} in your contacts. What is your {$relationship :i:inflect case=genitive} name?</source>
<print>I didn't find a brother in your contacts. What is your brother’s name?</print>
</test>
<test>
<params>
<param name="relationship" type="String"><value>aunt</value></param>
</params>
<source>I didn't find {$relationship :inflect definiteness=indefinite} in your contacts. What is your {$relationship :inflect case=genitive} name?</source>
<source>I didn't find {$relationship :i:inflect definiteness=indefinite} in your contacts. What is your {$relationship :i:inflect case=genitive} name?</source>
<print>I didn't find an aunt in your contacts. What is your aunt’s name?</print>
</test>
<test>
<params>
<param name="oridinalNum" type="Number"><value>4</value></param>
</params>
<source>Your {$oridinalNum :numeral withStyle=asWords withVariant=ordinal} meeting has been canceled</source>
<source>Your {$oridinalNum :i:numeral withStyle=asWords withVariant=ordinal} meeting has been canceled</source>
<print>Your fourth meeting has been canceled</print>
</test>
<test>
<params>
<param name="count" type="Number"><value>4</value></param>
</params>
<source>You have {$count :numeral withStyle=asSpokenWords} messages</source>
<source>You have {$count :i:numeral withStyle=asSpokenWords} messages</source>
<print>You have 4 messages</print>
<speak>You have four messages</speak>
</test>
Expand All @@ -92,37 +92,37 @@ plural {{The {$object} are on}}
<param name="n" type="Number"><value>1</value></param>
<param name="unit" type="String"><value>day</value></param>
</params>
<source>Your meeting is in {$unit :quantify withValue=$n} from now</source>
<source>Your meeting is in {$unit :i:quantify withValue=$n} from now</source>
<print>Your meeting is in 1 day from now</print>
</test>
<test>
<params>
<param name="n" type="Number"><value>2</value></param>
<param name="unit" type="String"><value>day</value></param>
</params>
<source>Your meeting is in {$unit :quantify withValue=$n} from now</source>
<source>Your meeting is in {$unit :i:quantify withValue=$n} from now</source>
<print>Your meeting is in 2 days from now</print>
</test>
<test>
<params>
<param name="n" type="Number"><value>3</value></param>
<param name="unit" type="String"><value>church</value></param>
</params>
<source>{$unit :quantify withValue=$n} were found nearby</source>
<source>{$unit :i:quantify withValue=$n} were found nearby</source>
<print>3 churches were found nearby</print>
</test>
<test>
<params>
<param name="word" type="String"><value>valid</value></param>
</params>
<source>{$word :inflect bogusFeature=value}</source>
<source>{$word :i:inflect bogusFeature=value}</source>
<print error="U_MF_FORMATTING_ERROR"/>
</test>
<test>
<params>
<param name="word" type="String"><value>valid</value></param>
</params>
<source>.local $v = {$word :inflect bogusFeature=value} .match $v
<source>.local $v = {$word :i:inflect bogusFeature=value} .match $v
* {{fallback}}
</source>
<print error="U_MF_SELECTOR_ERROR"/>
Expand All @@ -131,37 +131,37 @@ plural {{The {$object} are on}}
<params>
<param name="word" type="String"><value>valid</value></param>
</params>
<source>{$word :inflect to=bogus}</source>
<source>{$word :i:inflect to=bogus}</source>
<print>valid</print>
</test>
<test>
<params>
<param name="word" type="String"><value>valid</value></param>
</params>
<source>.local $v = {$word :inflect to=bogus} .match $v
<source>.local $v = {$word :i:inflect to=bogus} .match $v
valid {{is valid}}
* {{other}}
</source>
<print>other</print>
</test>
<test>
<params><param name="p" type="String"><value>her</value></param></params>
<source>{$p :pronoun gender=masculine}</source>
<source>{$p :i:pronoun gender=masculine}</source>
<print>his</print>
</test>
<test>
<params><param name="p" type="PronounConcept"><value>theirs</value></param></params>
<source>{$p :pronoun gender=masculine}</source>
<source>{$p :i:pronoun gender=masculine}</source>
<print>his</print>
</test>
<test>
<params><param name="p" type="PronounConcept"><value>he</value></param></params>
<source>{theirs :pronoun gender=$p}</source>
<source>{theirs :i:pronoun gender=$p}</source>
<print>his</print>
</test>
<test>
<params><param name="p" type="String"><value>she</value></param></params>
<source>.local $g = {$p :pronoun to=gender} .match $g
<source>.local $g = {$p :i:pronoun to=gender} .match $g
feminine {{feminine phrase}}
masculine {{masculine phrase}}
* {{other phrase}}
Expand All @@ -170,15 +170,15 @@ masculine {{masculine phrase}}
</test>
<test>
<params><param name="p" type="String"><value>garbage</value></param></params>
<source>{$p :pronoun}</source>
<source>{$p :i:pronoun}</source>
<print error="U_MF_FORMATTING_ERROR"/>
</test>
<test>
<params>
<param name="p" type="String"><value>her</value></param>
<param name="obj" type="String"><value>cat</value></param>
</params>
<source>{$p :pronoun to=gender withReferent=$obj}</source>
<source>{$p :i:pronoun to=gender withReferent=$obj}</source>
<print error="U_MF_FORMATTING_ERROR"/>
</test>
<test>
Expand All @@ -189,7 +189,7 @@ masculine {{masculine phrase}}
<value constraint="third singular genitive">xyr</value>
</param>
</params>
<source>{$np :pronoun case=accusative} {$np :pronoun}</source>
<source>{$np :i:pronoun case=accusative} {$np :i:pronoun}</source>
<print>xem xe</print>
</test>
</message2test>
Loading
Loading