@os-team/plural-forms

Declines nouns in the plural form. English and Russian languages are supported.

Usage no npm install needed!

<script type="module">
  import osTeamPluralForms from 'https://cdn.skypack.dev/@os-team/plural-forms';
</script>

README

@os-team/plural-forms NPM version BundlePhobia

Declines nouns in the plural form. English and Russian languages are supported.

Usage

Install the package using the following command:

yarn add @os-team/plural-forms

Example 1. English language

const years = 21;
const yearsPluralForm = pluralForms({
  language: 'en',
  forms: ['year', 'years'],
  number: years,
});
console.log(`${years} ${yearsPluralForm}`); // 21 years

Example 2. Russian language

const years = 21;
const yearsPluralForm = pluralForms({
  language: 'ru',
  forms: ['год', 'года', 'лет'],
  number: years,
});
console.log(`${years} ${yearsPluralForm}`); // 21 год