plural-forms
Provides information about the plural forms from any language that you may know
Installation
yarn add plural-forms
npm install --save plural-forms
Usage example
import { getNPlurals } from 'plural-forms'
const englishPluralsNumber = getNPlurals('en');
Available methods
getNPlurals(language: string): number
- language - language ISO code.
Returns the number of plural forms for locale
Example:
import { getNPlurals } from 'plural-forms'
const englishPluralsNumber = getNPlurals('en');
getFormula(language: string) : string
- language - language ISO code.
Returns plural form formula for locale
Example:
import { getFormula } from 'plural-forms'
const englishPluralsNumber = getFormula('en');
getPluralFunc(language: string) : function
- 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'])
fn(2, ['banana', 'bananas'])
hasLang(language: string): boolean
- language - language ISO code
Returns if language definition exists in catalog
Example:
import { hasLang } from 'plural-forms'
hasLang('en')
hasLang('zzz')
getAvailLangs(): [string]
Returns list with all existing ISO codes of languages from the catalog.
Example
import { getAvailLangs } from 'plural-forms';
getAvailLangs()
getExamples(language: string): [{ plural: number, sample: number}]
Returns list with examples for plurals.
Example
import { getExamples } from 'plural-forms';
getExamples('uk')