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.
Since it is doing something pretty simple, it is as easy to use as you'd expect.
plural = Variables.Pluralizer.pluralize(myword);
singular = Variables.Pluralizer.singularize(plural);
Most of the code is just a list of English exceptions to general rules. Expecially to allow "singularize".
Not much to it, but I've liked having it around so maybe someone else will get some use out of it.
Pluralizer is part of the com.sebtools package. It is a free ColdFusion package and you can read more about it in my com.sebtools blog series. Check it out!
If you need any help with com.sebtools, or ColdFusion in general, let me know.
https://github.com/TeamCFML/teamcfml-inflector
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!