# plural-forms

> Provides information about the plural forms from any language that you may know

Latest version **0.5.5** (published 2023-09-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install plural-forms
pnpm add plural-forms
yarn add plural-forms
bun add plural-forms
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.5 |
| Published | 2023-09-25 |
| First published | 2017-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 62.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | a.mostovenko |
| Maintainers | alexander |

## Links

- npm: https://www.npmjs.com/package/plural-forms
- Repository: https://github.com/c-3po-org/plural-forms
- Homepage: https://github.com/c-3po-org/plural-forms#readme
- Issues: https://github.com/c-3po-org/plural-forms/issues
- npm.io page: https://npm.io/package/plural-forms

## Recent versions

- 0.5.5 (latest) — 2023-09-25
- 0.5.3 — 2021-01-20
- 0.5.2 — 2020-11-02
- 0.5.1 — 2020-01-30
- 0.5.0 — 2020-01-30
- 0.4.0 — 2020-01-30
- 0.3.10 — 2019-09-30
- 0.3.9 — 2019-09-30
- 0.3.8 — 2019-09-30
- 0.3.7 — 2019-09-30
- 0.3.6 — 2019-09-28
- 0.3.5 — 2019-09-28
- 0.3.4 — 2019-09-28
- 0.3.3 — 2019-03-15
- 0.3.2 — 2019-03-14
- … 9 more at https://npm.io/package/plural-forms/versions

## README

# plural-forms
Provides information about the plural forms from any language that you may know

## Installation

```bash
yarn add plural-forms
# or
npm install --save plural-forms
```

## Usage example
```js
import { getNPlurals } from 'plural-forms'

const englishPluralsNumber = getNPlurals('en'); // 2 
```

## Available methods

### getNPlurals(language: string): number
* *language* - language ISO code.
Returns the number of plural forms for locale

**Example**:

```js
import { getNPlurals } from 'plural-forms'

const englishPluralsNumber = getNPlurals('en'); // 2 
```

### getFormula(language: string) : string
* *language* - language ISO code.
Returns plural form formula for locale

**Example**:

```js
import { getFormula } from 'plural-forms'

const englishPluralsNumber = getFormula('en'); // "n!==1'"
```

### getPluralFunc(language: string) : function
* *language* - language ISO code.
Returns function that can compute appropriate form for locale

**Example**:

```js
import { getPluralFunc } from 'plural-forms'
const fn = getPluralFunc('en')

fn(1, ['banana', 'bananas']) // 'banana'
fn(2, ['banana', 'bananas']) // 'bananas'
```

### hasLang(language: string): boolean
* *language* - language ISO code
Returns if language definition exists in catalog

**Example**:

```js
import { hasLang } from 'plural-forms'
hasLang('en') // true
hasLang('zzz') // false
```

## getAvailLangs(): [string]
Returns list with all existing ISO codes of languages from the catalog.

**Example**

```js
import { getAvailLangs } from 'plural-forms';
getAvailLangs() // [en, uk, ...]
```

## getExamples(language: string): [{ plural: number, sample: number}]
Returns list with examples for plurals.

**Example**

```js
import { getExamples } from 'plural-forms';
getExamples('uk')
// [ { plural: 0, sample: 1 },
//   { plural: 1, sample: 2 },
//   { plural: 2, sample: 5 } ]
```

---
_Source: https://npm.io/package/plural-forms · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
