Provides information about the plural forms from any language that you may know
yarn add plural-forms
# or
npm install --save plural-forms
import { getNPlurals } from 'plural-forms'
const englishPluralsNumber = getNPlurals('en'); // 2
- language - language ISO code. Returns the number of plural forms for locale
Example:
import { getNPlurals } from 'plural-forms'
const englishPluralsNumber = getNPlurals('en'); // 2
- language - language ISO code. Returns plural form formula for locale
Example:
import { getFormula } from 'plural-forms'
const englishPluralsNumber = getFormula('en'); // "n!==1'"
- language - language ISO code. Returns function that can compute appropriate form for locale
Example:
import { getPluralFunc } from 'plural-forms'
const fn = getPluralFunc('en')
fn(1, ['banana', 'bananas']) // 'banana'
fn(2, ['banana', 'bananas']) // 'bananas'
- language - language ISO code Returns if language definition exists in catalog
Example:
import { hasLang } from 'plural-forms'
hasLang('en') // true
hasLang('zzz') // false
Returns list with all existing ISO codes of languages from the catalog.
Example
import { getAvailLangs } from 'plural-forms';
getAvailLangs() // [en, uk, ...]
Returns list with examples for plurals.
Example
import { getExamples } from 'plural-forms';
getExamples('uk')
// [ { plural: 0, sample: 1 },
// { plural: 1, sample: 2 },
// { plural: 2, sample: 5 } ]