* 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)
| 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 | /** |