4 ms·
Nice, I didn't know that about Arabic, and the many other languages. Though i18n-js does let you write your own pluralizations rules (taken from the readme), w
by mikewhy 12y ago
Nice, I didn't know that about Arabic, and the many other languages.
Though i18n-js does let you write your own pluralizations rules (taken from the readme), while supporting zero/one/many out of the box:
I18n.pluralization["ru"] = function (count) {
var key = count % 10 == 1 && count % 100 != 11 ? "one" : [2, 3, 4].indexOf(count % 10) >= 0 && [12, 13, 14].indexOf(count % 100) < 0 ? "few" : count % 10 == 0 || [5, 6, 7, 8, 9].indexOf(count % 10) >= 0 || [11, 12, 13, 14].indexOf(count % 100) >= 0 ? "many" : "other";
return [key];
};
I've posted an example below, but I don't consider `@div null, @t('welcomeMessage', { username })` "littering" my code.
- drewfish 12y agoThere are a few NPM libraries (make-plural, cldr, probably others) which will help you write those pluralization functions. The CLDR data does get updated from time to time, so it's nice to rely on another package to trace those changes.