Fix language fallback'ing

This commit is contained in:
KingRainbow44
2022-05-07 23:44:35 -04:00
parent 50307ea3a9
commit 549471b76e
2 changed files with 11 additions and 3 deletions

View File

@@ -48,11 +48,13 @@ public final class Language {
try {
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
if(file == null) {
String translationContents = Utils.readFromInputStream(file);
if(translationContents.equals("empty")) {
file = Grasscutter.class.getResourceAsStream("/languages/" + fallback);
translationContents = Utils.readFromInputStream(file);
}
languageData = Grasscutter.getGsonFactory().fromJson(Utils.readFromInputStream(file), JsonObject.class);
languageData = Grasscutter.getGsonFactory().fromJson(translationContents, JsonObject.class);
} catch (Exception exception) {
Grasscutter.getLogger().warn("Failed to load language file: " + fileName, exception);
}