Description
Is your feature request related to a problem? Please describe.
There should be a generic way to handle conditionals. When getting words into grammatical agreement, word choice can depend on the grammatical properties and values of other words.
Issue #21 goes into a discussion about ranges that is similar to ICU ChoiceFormat. It seems like shorthand to needing a more complete conditional handling. Issue #31 goes into detecting grammatical category values (grammemes), but you need to act upon a given value. A translator may need to choose a different verb or adjective depending on the noun inserted into a message.
Describe the solution you'd like
I'll try to avoid using the XML or UEL syntax that I'm used to using in the solution description. I'll just state what should be considered.
- "if then {show span}". An alternative is to have a span of text just have a condition for being shown.
- "if then {show span} else {show other span}". An alternative is to have a list of text spans, and each span that has a condition on it. The first span that has a conditional that evaluates to true is chosen, and there must be a default span at the end. The alternative would be easier for else-if statements.
- The <, >, <=, >=, == (not assignment), !=, && (and), || (or) should be supported
- Comparisons should be against numbers and strings. Though perhaps it's best to just do equals for strings so that you can compare against the gender, grammatical number or other grammatical category values of the string.
- Switch statements so that you can compare against masculine, feminine, neuter, and unknown. ICU gender format isn't generic enough.
- If a variable is null or invalid, a span of text is omitted.
- If a span of text is chosen to be shown, allow it to be detected as being selected to allow for grammatical agreement later in a sentence. This is helpful for split verbs, which have been known to be used for German and Cantonese.
Describe why your solution should shape the standard
This is a way to get words to agree with each other. The several message formatting options from ICU don't have the same syntax. It would be better if it were consistent for handling conditionals to ease the learning curve.
Additional context or examples
#21
ICU ChoiceFormat
ICU PluralFormat
ICU GenderFormat