@formatjs/intl-pluralrules
Version:
Polyfill for Intl.PluralRules
26 lines (25 loc) • 1.07 kB
JavaScript
/* @generated */
// prettier-ignore
if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["many","one","other"],"ordinal":["many","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 e = exponent;
if (isOrdinal) {
if ((((n === 11 || n === 8) || (n >= 80 && n <= 89)) || (n >= 800 && n <= 899)))
return "many";
}
else {
if (e === 0 && i !== 0 && (i % 1000000) === 0 && v === 0 || (e < 0 || e > 5))
return "many";
if (i === 1 && v === 0)
return "one";
}
return "other";
},"pluralRanges":{"cardinal":{"one_other":"other","other_one":"one","other_other":"other"},"ordinal":{}}},"locale":"scn"})
}