You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
839 B

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../utils");
var PLURAL_FORMAT_OPTIONS = [
'localeMatcher',
'type',
];
function formatPlural(_a, getPluralRules, value, options) {
var locale = _a.locale, onError = _a.onError;
if (options === void 0) { options = {}; }
if (!Intl.PluralRules) {
onError(utils_1.createError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n"));
}
var filteredOptions = utils_1.filterProps(options, PLURAL_FORMAT_OPTIONS);
try {
return getPluralRules(locale, filteredOptions).select(value);
}
catch (e) {
onError(utils_1.createError('Error formatting plural.', e));
}
return 'other';
}
exports.formatPlural = formatPlural;