Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.toPlural

toPlural($quantity=2, $pluralWord='') -> string

Description

Return the plural form of the string, if $quantity is not 1.

If $pluralWord is an empty string, it returns a basic English plural by appending either “s” or “es”.

'T-Rex'.toPlural()
//= 'T-Rexes'

'T-Rex'.toPlural(1)
//= 'T-Rex'

'turtle'.toPlural(2)
//= 'turtles'

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

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

See Also