Pluralizing in ColdFusion

A few (ok, ten) years ago, I needed to generically pluralize English words in ColdFusion. Also, I wanted to be able to reverse that out ("singularize" as it were). This should be a really easy problem: If it ends with an "s" then add "es"; If it ends with a "y" then ditch the "y"; Otherwise just add "s". It turns out, though, that English is delightfully complicated.

So, Pluralizer.

I created it ten years ago, and I've used a fair number of times since. It isn't complicated enough that I've needed to update it much in that time.


Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Have you compared the results with other libraries? I use an inflector CFC and I see that some of the logic is different and their module has some additional string functions that may be beneficial.
# Posted By James Moberg | 9/23/20 3:19 PM

Sorry I missed your comment earlier. I haven't compared to other libraries. I didn't even know that one existed. Honestly, I think it looks better than mine. Very nice!
# Posted By Steve Bryant | 10/28/20 9:47 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.