v0.3.4: improved the consistency of title case
This commit is contained in:
parent
aed5e994b3
commit
f5a5390d61
|
@ -31,8 +31,8 @@ public enum Languages {
|
||||||
CHINESE("中文", "zh", Status.UNREVIEWED, new String[]{"Jinkeloid"}, new String[]{"931451545", "HoofBumpBlurryface", "Lyn-0401", "ShatteredFlameBlast", "Tempest102"}),
|
CHINESE("中文", "zh", Status.UNREVIEWED, new String[]{"Jinkeloid"}, new String[]{"931451545", "HoofBumpBlurryface", "Lyn-0401", "ShatteredFlameBlast", "Tempest102"}),
|
||||||
//Brazillian
|
//Brazillian
|
||||||
PORTUGUESE("português", "pt", Status.UNREVIEWED, new String[]{"Matheus208"}, new String[]{"JST", "Try31"}),
|
PORTUGUESE("português", "pt", Status.UNREVIEWED, new String[]{"Matheus208"}, new String[]{"JST", "Try31"}),
|
||||||
|
GERMAN("deutsch", "de", Status.UNREVIEWED, new String[]{"Davedude", "KrystalCroft"}, new String[]{"DarkPixel", "ErichME", "Sarius", "Zap0", "Oragothen"}),
|
||||||
|
|
||||||
GERMAN("deutsch", "de", Status.INCOMPLETE, new String[]{"Davedude", "KrystalCroft"}, new String[]{"DarkPixel", "ErichME", "Sarius", "Zap0", "Oragothen"}),
|
|
||||||
POLISH("polski", "pl", Status.INCOMPLETE, null, new String[]{"Darden", "Deksippos", "Scharnvirk", "Wawrzyn"}),
|
POLISH("polski", "pl", Status.INCOMPLETE, null, new String[]{"Darden", "Deksippos", "Scharnvirk", "Wawrzyn"}),
|
||||||
SPANISH("español", "es", Status.INCOMPLETE, null, new String[]{"CorvosUtopy", "LucasCamilo", "Luuciano96", "Prancer", "Talruin", "Ctrijueque", "Grayscales", "Jonismack1", "Pixeled4life"}),
|
SPANISH("español", "es", Status.INCOMPLETE, null, new String[]{"CorvosUtopy", "LucasCamilo", "Luuciano96", "Prancer", "Talruin", "Ctrijueque", "Grayscales", "Jonismack1", "Pixeled4life"}),
|
||||||
FRENCH("français", "fr", Status.INCOMPLETE, null, new String[]{"Kultissim", "Minikrob"});
|
FRENCH("français", "fr", Status.INCOMPLETE, null, new String[]{"Kultissim", "Minikrob"});
|
||||||
|
|
|
@ -153,23 +153,25 @@ public class Messages {
|
||||||
private static final HashSet<String> noCaps = new HashSet<>(
|
private static final HashSet<String> noCaps = new HashSet<>(
|
||||||
Arrays.asList(new String[]{
|
Arrays.asList(new String[]{
|
||||||
//English
|
//English
|
||||||
"a", "of",
|
"a", "of", "by",
|
||||||
//French
|
|
||||||
"à", "avec", "de", "du", "des",
|
|
||||||
//Portugese
|
|
||||||
"a", "de", "des", "da", "das", "do", "dos",
|
|
||||||
//German
|
//German
|
||||||
"der", "des",
|
"der", "des", "von",
|
||||||
//Russian
|
|
||||||
"с", //Not an english c, looks just like it though.
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
public static String titleCase( String str ){
|
public static String titleCase( String str ){
|
||||||
|
//These languages don't do capitalization
|
||||||
|
if (lang == Languages.CHINESE || lang == Languages.KOREAN){
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//These languages capitalize every word except for a few exceptions
|
||||||
|
//...Yes technically German is just every noun, but this should be close enough.
|
||||||
|
if (lang == Languages.ENGLISH || lang == Languages.GERMAN){
|
||||||
String result = "";
|
String result = "";
|
||||||
//split by any unicode space character
|
//split by any unicode space character
|
||||||
for (String word : str.split("(?<=\\p{Zs})")){
|
for (String word : str.split("(?<=\\p{Zs})")){
|
||||||
if (noCaps.contains(word.trim().toLowerCase())){
|
if (noCaps.contains(word.trim().toLowerCase().replaceAll(":", ""))){
|
||||||
result += word;
|
result += word;
|
||||||
} else {
|
} else {
|
||||||
result += capitalize(word);
|
result += capitalize(word);
|
||||||
|
@ -178,4 +180,8 @@ public class Messages {
|
||||||
//first character is always capitalized.
|
//first character is always capitalized.
|
||||||
return capitalize(result);
|
return capitalize(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Otherwise, the language uses sentence case
|
||||||
|
return capitalize(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user