Pluralize and singularize any word


Pluralize and singularize any word.

npm install pluralize --save
bower install pluralize --save
var pluralize = require('pluralize')
define(function (requireexportsmodule) {
  var pluralize = require('pluralize')
<script src="pluralize.js"></script>

This module uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word. There are many cases where this is useful, such as any automation based on user input. For applications where the word(s) are known ahead of time, you can use a simple ternary (or function) which would be a much lighter alternative.

pluralize('test') //=> "tests" 
pluralize('test', 1) //=> "test" 
pluralize('test', 5) //=> "tests" 
pluralize('test', 1, true) //=> "1 test" 
pluralize('test', 5, true) //=> "5 tests" 
pluralize.plural('regex') //=> "regexes" 
pluralize.addPluralRule(/gex$/i, 'gexii')
pluralize.plural('regex') //=> "regexii" 
pluralize.plural('singles', 1) //=> "single" 
pluralize.addSingularRule(/singles$/i, 'singular')
pluralize.plural('singles', 1) //=> "singular" 
pluralize.plural('irregular') //=> "irregulars" 
pluralize.addIrregularRule('irregular', 'regular')
pluralize.plural('irregular') //=> "regular" 
pluralize.plural('paper') //=> "papers" 
pluralize.plural('paper') //=> "paper"