Possible Duplicate:
Plural form of a word
Is there some existing class or library for adding “s” to a String if I pass it a number that’s not 1? Basically, I have a cat. If I have 1 cat, I need the String “cat”. If I have 2 cats, I need the String “cats”. It’s a simple thing to do myself, but after I did it, I thought there’s probably already a library I could import for it. However, as you can see, I am having difficulty putting this into words to Google a name for the package, if it exists. 😛 It’s just that I write this function all the time, I’m wondering if it exists already.
Pluralizing is probably simple enough, with the exception of the list of words like “cactus” or “tooth” that are somewhat special cases, that you don’t need an entire API or you can implement yourself. If you really don’t want to have a stab at it, there are things like the
Inflectorlibrary that can do it for you. There are probably others, if you search for “java pluralize”.Javadocs for Inflector here: http://www.atteo.org/static/evo-inflector/apidocs/index.html