mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
pluralize: matrix, index, medium
This commit is contained in:
@@ -795,11 +795,21 @@ public class StringUtil extends StringUtilRt {
|
||||
return suggestion;
|
||||
}
|
||||
|
||||
int len = suggestion.length();
|
||||
if (endsWithIgnoreCase(suggestion, "ex") || endsWithIgnoreCase(suggestion, "ix")) {
|
||||
return suggestion.substring(0, len - 2) + "ices";
|
||||
}
|
||||
if (endsWithIgnoreCase(suggestion, "um")) {
|
||||
return suggestion.substring(0, len - 2) + "a";
|
||||
}
|
||||
if (endsWithIgnoreCase(suggestion, "an")) {
|
||||
return suggestion.substring(0, len - 2) + "en";
|
||||
}
|
||||
|
||||
if (endsWithIgnoreCase(suggestion, "s") || endsWithIgnoreCase(suggestion, "x") || endsWithIgnoreCase(suggestion, "ch")) {
|
||||
return suggestion + "es";
|
||||
}
|
||||
|
||||
int len = suggestion.length();
|
||||
if (endsWithIgnoreCase(suggestion, "y") && len > 1 && !isVowel(toLowerCase(suggestion.charAt(len - 2)))) {
|
||||
return suggestion.substring(0, len - 1) + "ies";
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ public class StringUtilTest {
|
||||
public void testPluralize() {
|
||||
assertEquals("values", StringUtil.pluralize("value"));
|
||||
assertEquals("values", StringUtil.pluralize("values"));
|
||||
assertEquals("indices", StringUtil.pluralize("index"));
|
||||
assertEquals("matrices", StringUtil.pluralize("matrix"));
|
||||
assertEquals("men", StringUtil.pluralize("man"));
|
||||
assertEquals("media", StringUtil.pluralize("medium"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user