Skip to content

pluralize

Import from @varavel/vdl-plugin-sdk/utils/strings.

function pluralize(
   word, 
   count?, 
   inclusive?): string;

Pluralize or singularize a word based on a count.

This function uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word.

Parameters

Parameter Type Description
word string The word to pluralize or singularize.
count? number Optional number indicating how many of the word exist. - If 1, returns the singular form. - If other than 1, returns the plural form.
inclusive? boolean Whether to prefix the result with the number (e.g., "3 ducks"). Defaults to false.

Returns

string

The pluralized or singularized word, optionally prefixed by the count.

Example

pluralize('test')
// "tests"

pluralize('test', 1)
// "test"

pluralize('test', 5, true)
// "5 tests"

pluralize('person', 2)
// "people"

See

Powered by pluralize (MIT License): https://github.com/plurals/pluralize