@formatjs/intl-pluralrules
Version:
Polyfill for Intl.PluralRules
23 lines (22 loc) • 1.15 kB
JavaScript
/* @generated */
// prettier-ignore
if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other","zero"],"ordinal":["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 v = decimalPart.length;
const f = v > 0 ? parseInt(decimalPart, 10) : 0;
if (isOrdinal) {
}
else {
if ((n % 10) === 1 && (n % 100) !== 11 || v === 2 && (f % 10) === 1 && (f % 100) !== 11 || v !== 2 && (f % 10) === 1)
return "one";
if ((n % 10) === 0 || ((n % 100) >= 11 && (n % 100) <= 19) || v === 2 && ((f % 100) >= 11 && (f % 100) <= 19))
return "zero";
}
return "other";
},"pluralRanges":{"cardinal":{"one_one":"one","one_other":"other","one_zero":"other","other_one":"one","other_other":"other","other_zero":"other","zero_one":"one","zero_other":"other","zero_zero":"other"},"ordinal":{}}},"locale":"lv"})
}