New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

js-simple-plurals

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-simple-plurals

Just a set of plural functions for different languages

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

js-simple-plurals

Just a set of plural functions for different languages

Installation

Install with Bower

$ bower install js-simple-plurals

Install with NPM

$ npm install js-simple-plurals

Examples

Node.js

var plural = require('./node/en');
function pluralizeEn(number, one, many) {
    var rules = [one, many];
    var position = plural(number);
    return rules[position];
}

console.log('2 ' + pluralizeEn(2, 'day', 'days')); // prints '2 days'

Web

<form>
    <label>
        Number
        <input type="number" id="number" value="1">
    </label>
    <div id="text"></div>
</form>

<script src="web/en.js"></script>
<script>
    var number = document.getElementById('number');
    var text   = document.getElementById('text');

    function pluralizeEn(number, one, many) {
        var rules = [one, many];
        var position = plural.en(number);
        return rules[position];
    }

    function updateText() {
        var content = number.value + ': ' + pluralizeEn(
            number.value,
            'day',
            'days'
        );
        document.getElementById('text').textContent = content;
    }

    document.getElementById('number').addEventListener('change', updateText);
    updateText();
</script>

About

Plural rules follow the guideline found in the Unicode CLDR Charts on Language Plural Rules. This plural rules are based on rules generated by universal-i18n.

Keywords

javascript

FAQs

Package last updated on 29 Jan 2016

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