List of utility methods to do String Pluralize
String | pluralize(String word) Get the plural for the given English word. if (word == null) { throw new IllegalArgumentException(); final String lowerCaseWord = word.toLowerCase(); if (endsWithAny(lowerCaseWord, "s", "sh", "o")) { return word + "es"; if (lowerCaseWord.endsWith("y") && !lowerCaseWord.endsWith("ay") ... |
String | pluralize(String word, int count) pluralize if (count != 1) { return word + "s"; return word; |
String | pluralize(String x, Integer y) pluralize return (y == 1 ? x : x + "s"); |
String | pluralizeName(String name) pluralize Name if (name.endsWith("s")) return name + "'"; return name + "'s"; |
String | pluralName(final String name) plural Name String pluralName; if (name.endsWith("y")) { pluralName = name.substring(0, name.length() - 1) + "ies"; } else if (name.endsWith("s") || name.endsWith("x")) { pluralName = name + "es"; } else { pluralName = name + 's'; return pluralName; |
String | PluralTemplateHelper(int count, String singularTemplate, String pluralTemplate) For even more complex sentences, it may just be easiest to provide a template, which will be replaced, if the count is singular or plural. if (count == 1) { return String.format(singularTemplate, count); } else { return String.format(pluralTemplate, count); |