@formatjs/intl-pluralrules
Version:
Polyfill for Intl.PluralRules
25 lines (24 loc) • 952 B
JavaScript
/* @generated */
// prettier-ignore
if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["few","one","other","two"],"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 i = Math.floor(Math.abs(parseFloat(integerPart)));
const v = decimalPart.length;
const f = v > 0 ? parseInt(decimalPart, 10) : 0;
if (isOrdinal) {
}
else {
if (v === 0 && ((i % 100) >= 3 && (i % 100) <= 4) || ((f % 100) >= 3 && (f % 100) <= 4))
return "few";
if (v === 0 && (i % 100) === 1 || (f % 100) === 1)
return "one";
if (v === 0 && (i % 100) === 2 || (f % 100) === 2)
return "two";
}
return "other";
}},"locale":"dsb"})
}