It is always statically frustrating / tedious and awful code you need to write when you have to pluralize or singularize a word. What is even worse is when people don’t bother doing that and just leave the singularized word in a grammatically incorrect state, glaring the user in the eye.
Most people forget, or just haven’t taken notice to a nicely hidden service in the System.Data.Entity.Design namespace titled: PluralizationService. This service is available as of .NET 4 and up, and offers exactly what you think it would. The ability to convert a word to singular or plural, and also identify if a word is already pluralized or singularized. Never again, should you have an excuse for messy or unwritten code in relation to pluralization.
Check out the MSDN definition:
Check out this blog that gives a code snippet for simple usage:
http://zquanghoangz.blogspot.ca/2012/02/beginner-with-pluralizationservices.html
Happy pluralizing!!
Thanks for the tip Travis, I’ll have to check it out. I use a great little library called Humanizer for this. It pluralizes words and a lot more:
https://github.com/MehdiK/Humanizer
I just took a look at the Humanizer library. This indeed does look awesome. Thanks for passing this along Michael, I may just use it in my next project!