UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

26 lines (24 loc) 759 B
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_utils_intl = require('../utils/intl.cjs'); //#region src/interpreter/getPlural.ts /** * Picks content from a plural map based on a count and locale, using CLDR * pluralization rules (`Intl.PluralRules`). * * Falls back to the `other` category when no specific category matches. * * @example * ```ts * getPlural({ * one: 'one item', * other: '{{count}} items', * }, 5, 'en'); * // '{{count}} items' * ``` */ const getPlural = (pluralContent, count, locale) => { return pluralContent[require_utils_intl.getCachedIntl(Intl.PluralRules, locale).select(count)] ?? pluralContent.other; }; //#endregion exports.getPlural = getPlural; //# sourceMappingURL=getPlural.cjs.map