It will use the english as default rather than tell you the value is not exist if there's no translation for currently language

This commit is contained in:
Secretboy-SMR 2022-05-11 21:14:07 +08:00 committed by Melledy
parent 89bd4b9aeb
commit 1f7f13ffe1

View File

@ -160,7 +160,9 @@ public final class Language {
JsonObject object = this.languageData;
int index = 0;
String result = "This value does not exist. Please report this to the Discord: " + key;
String valueNotFoundPattern = "This value does not exist. Please report this to the Discord: ";
String result = valueNotFoundPattern + key;
boolean isValueFound = false;
while (true) {
if(index == keys.length) break;
@ -171,10 +173,18 @@ public final class Language {
if(element.isJsonObject())
object = element.getAsJsonObject();
else {
isValueFound = true;
result = element.getAsString(); break;
}
} else break;
}
if (!isValueFound && !languageCode.equals("en-US")) {
var englishValue = Grasscutter.getLanguage("en-US").get(key);
if (!englishValue.contains(valueNotFoundPattern)) {
result += "\nhere is english version:\n" + englishValue;
}
}
this.cachedTranslations.put(key, result); return result;
}