Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

plural-forms

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plural-forms

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

  • 0.5.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
49K
increased by10.84%
Maintainers
1
Weekly downloads
 
Created
Source

plural-forms

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

Installation

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

Usage example

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:

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:

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:

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:

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

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

getExamples(language: string): [{ plural: number, sample: number}]

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 } ]

FAQs

Package last updated on 25 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc