@formatjs/intl-pluralrules
Version:
Polyfill for Intl.PluralRules
24 lines (23 loc) • 1.08 kB
JavaScript
/* @generated */
// prettier-ignore
if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["one","other"]},"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));
const i = Math.floor(Math.abs(parseFloat(integerPart)));
const v = decimalPart.length;
const f = v > 0 ? parseInt(decimalPart, 10) : 0;
if (isOrdinal) {
if (n === 1)
return "one";
}
else {
if (v === 0 && ((i === 1 || i === 2) || i === 3) || v === 0 && (((i % 10) !== 4 && (i % 10) !== 6) && (i % 10) !== 9) || v !== 0 && (((f % 10) !== 4 && (f % 10) !== 6) && (f % 10) !== 9))
return "one";
}
return "other";
},"pluralRanges":{"cardinal":{"one_one":"one","one_other":"other","other_one":"one","other_other":"other"},"ordinal":{}}},"locale":"fil"})
}