Closed r-aamir closed 5 years ago
Support for more complex pluralisation rules has been on my radar for a while. I will probably have a chance to implement something in the next couple of weeks. My initial thoughts would be to support the rules through a plugin interface rather than baking them into the core.
Ok, just pushed an update. I implemented the more complex rules as an extension point. The implementation for Russian (based on your example) lives here.
https://github.com/roddeh/i18njs-ru
Then the usage would be something like
let ru = i18n.create({
values:{
"%n results":{
"zero": "нет результатов",
"one": "%n результат",
"few": "%n результата",
"many": "%n результатов",
"other": "%n результаты"
}
}
)
const russianExt = require('i18njs-ru')
ru.extend(russianExt)
ru('%n results', 0)
ru('%n results', 1)
ru('%n results', 11)
ru('%n results', 101)
...
Let me know if you think this will work. I am not so familiar with Russian ;)
Once you confirm I will publish both packages to npm.
Just published to npm
Sorry for late response, just tested and it works great, thanks!
Is it planned to include ability to specify pluralization rules for a language such as Russian, where there are much more word forms depending on the count of objects, such as:
Russian pluralization rules:
Pluralization rules can be found at http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html