MCPcopy Create free account
hub / github.com/facebook/Rapid / pluralRule

Method pluralRule

modules/core/LocalizationSystem.js:317–325  ·  view source on GitHub ↗

* pluralRule * Returns the plural rule for the given `number` with the given `code`. * see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/select * * @param {number} number - number to get the plural rule * @param {string?} local

(number, locale = this._currLocaleCode)

Source from the content-addressed store, hash-verified

315 * @return {string} One of: `zero`, `one`, `two`, `few`, `many`, `other`
316 */
317 pluralRule(number, locale = this._currLocaleCode) {
318 // modern browsers have this functionality built-in
319 const rules = 'Intl' in window && Intl.PluralRules && new Intl.PluralRules(locale);
320 if (rules) {
321 return rules.select(number);
322 }
323 // fallback to basic one/other, as in English
324 return (number === 1) ? 'one' : 'other';
325 }
326
327
328 /**

Callers 1

_resolveStringMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected