An implementation of MF2 with column-first selection #369
Replies: 3 comments 2 replies
-
|
Good idea to use ordinals in English (quite similar to Slavic cardinals) |
Beta Was this translation helpful? Give feedback.
-
|
I've merged the Java implementation for best match selection. It is a copy of the existing ICU4J implementation, with the classes moved to a different package to avoid conflicts. It is maven, so all you need to do is I've added a dedicated test file ( And has an ordinal example: The commits are cleanly separated to show the progress, from an empty maven project to the final version. The changes needed are really minimal. |
Beta Was this translation helpful? Give feedback.
-
|
Following #372, I've merged this into the JS polyfill in messageformat/messageformat#395. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Following yesterday's discussion, I've updated my JS
Intl.MessageFormatpolyfill to provide two up-to-date implementations with the following selection method alternatives:The change in getting from the former to the latter is effectively commit
f5d1bba, which changes the message value selection method frommatchSelectKey(key: string): booleantoselectKey(keys: Set<string>): string | null. The actual selection algorithm is found in thegetPattern()function inmessage-value/resolved-message.ts.To play around with this locally, run one of the above shell commands and then create a new file
test.mjswith these contents:then run
node test.mjsto observe the results. With4.0.0-3, thewhen one 1variant will be selected, while4.0.0-3.cfwill selectwhen 1 1. You may run the correspondingnpm installcommand to switch from one to another.To experiment with more complex rules while staying in English, the
:numberfunction supports thetype=ordinaloption to perform ordinal rather than cardinal selection.CC @aphillips, @stasm, @mihnita
Beta Was this translation helpful? Give feedback.
All reactions