@formatjs/intl-pluralrules
Version:
Polyfill for Intl.PluralRules
27 lines (26 loc) • 974 B
JavaScript
/* @generated */
// prettier-ignore
if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["few","many","one","other","two"]},"fn":function(num, isOrdinal, exponent = 0) {
const numStr = String(num);
const parts = numStr.split(".");
const integerPart = parts[0];
const decimalPart = parts[1] || "";
const n = Math.abs(parseFloat(numStr));
if (isOrdinal) {
if (n === 4)
return "few";
if (n === 6)
return "many";
if (((n === 1 || n === 5) || (n >= 7 && n <= 9)))
return "one";
if ((n === 2 || n === 3))
return "two";
}
else {
if (n === 1)
return "one";
}
return "other";
},"pluralRanges":{"cardinal":{"one_one":"other","one_other":"other","other_one":"one","other_other":"other"},"ordinal":{}}},"locale":"or"})
}