Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!

String.toPlural

toPlural($quantity, $pluralWord = '')

Description

Return the plural form if $quantity is not 1.

By default, it appends 's' or 'es'. Otherwise it returns $pluralWord.

'duck'.toPlural(1);
//= 'duck'

'duck'.toPlural(2);
//= 'ducks'

'horse'.toPlural(3);
//= 'horses'

'goose'.toPlural(1, 'geese');
//= 'goose'

'goose'.toPlural(2, 'geese');
//= 'geese'

See Also