Everything below is syntax independent.
It is not only addressing ICU plurals, but any kind of plurals (and selectors in general).
So it can deal with
Android plurals, or gettext/po plurals, or ICU syntax used in other filters (.properties, or .xml, or json)
(ICU syntax parser as a subfilter)
Docs:
XLIFF 2.x module to support plural / gender / select (draft)
Plural and gender support in XLIFF 2.x
The first doc is the proposal for the XLIFF 2.x standard, so it is more focused on the xml representation part.
The second one is more about explaining the problem, examples, how to deal with it and why.
Code:
Branches with code prototyping:
mihai_plural_xliff : This is Okapi code that would deal with plurals. Most concepts are represented with annotations.
The xliff in this case is 1.2, with special namespaces, but the concepts are very similar with the 2.x official proposal.
mihai_stream_step : This is code that would allow the application of a sub-filter as a step, without being invoked by the main filter.
You can do something like excel_filter => step(filter_wrap(xml_filter)) => step(filter_wrap(html_filter)) ...
And the implementation can also do n:m mapping.
So you can get 1 TextUnit event that contains an ICU message and produce a group with 2 TextUnits for singular and plural.
Then you can get the 2 events in the "black box" and produce 4 (for instance to take singular and plural TextUnit from English and produce 4 TextUnit(s) needed for the Russian plurals, in a separate step.
Bottleneck:
Representing and processing "message level selectors" is easy:
{count, plural,
=1 {You deleted one file from folder {folderName}}
other {You deleted {count} files from folder {folderName}}
}
"Internal selectors" (where the selection is done on a substring) is another can of worms.
You deleted {count, plural, =1 {one file} other {{count} files}} from folder {folderName}
My current proposal is to not support the second form at all, and to add a conversion to the first form.
The second form is not very difficult to represent in xliff (I have a section for it in the 2.x proposal).
But it is difficult for translators (they would have to "drag inside the selector" words that are outside in English in order to deal with agreement in gender / number / grammatical case) and would completely mess up validation (the number of placeholders would change).
And it is bad i18n to begin with, it's technically concatenation.
For ICU that can be done almost 100% algorithmically, except for special crazy cases where you have two or more plurals with offset.
(multiple plurals are fine, but maximum one can have offset)
I can't think of a good example of a string using that, except something very unnatural.
I have code for that somewhere (but not in opaki branches, or anywhere public)
Other formats that I am aware of (Android XML, po files) don't support that kind of internal selection at all.
Cheers,
Mihai