Improve plural examples
This is an offshoot of discussion in #2780.
Previously in French, and more recently in at least Spanish, Catalan, Portuguese, and Italian, the many CLDR plural category has been added for millions, as in "1 000 000 de jours". Our current algorithm will never find an example value for this, as it terminates its search at 1000.
Separately from that, some locales have specific rules for numbers that are formatted as 0.0 and 0.1, which this search will also never find.
We're also currently relying on our self-defined plural category rules for these examples, which e.g. don't include the French many. If we were to rely on Intl.PluralRules instead, the situation could be improved.
As for the search space, the following would appear to be an exhaustive set of examples we ought to be trying:
[
'0', '1',
'2', '3',
'6', '7',
'11', '21',
'1000000', '0.0',
'0.1'
]
Based on data from CLDR gathered using this script
import * as examples from 'make-plural/examples'
let data = []
for (let cat of ['zero', 'one', 'two', 'few', 'many', 'other']) {
for (let { cardinal } of Object.values(examples)) {
if (cardinal[cat]) data.push(cardinal[cat])
}
}
const res = []
while (data.length) {
const ex = data[0][0]
res.push(ex)
data = data.filter(row => !row.includes(ex))
}
res.sort((a, b) => {
const af = a.includes('.')
const bf = b.includes('.')
if (af) return bf && a < b ? -1 : 1
else return bf || Number(a) < Number(b) ? -1 : 1
})
console.log(res)