Commit 137ea1e2 authored by KingRainbow44's avatar KingRainbow44 Committed by Melledy
Browse files

Fallback to the fallback fallback

parent 09801a18
......@@ -46,12 +46,15 @@ public final class Language {
private Language(String fileName, String fallback) {
@Nullable JsonObject languageData = null;
try {
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
if(file == null) {
if(file == null) // Provided fallback language.
file = Grasscutter.class.getResourceAsStream("/languages/" + fallback);
}
if(file == null) // Fallback the fallback language.
file = Grasscutter.class.getResourceAsStream("/languages/en-US.json");
if(file == null)
throw new RuntimeException("Unable to load the primary, fallback, and 'en-US' language files.");
try {
languageData = Grasscutter.getGsonFactory().fromJson(Utils.readFromInputStream(file), JsonObject.class);
} catch (Exception exception) {
Grasscutter.getLogger().warn("Failed to load language file: " + fileName, exception);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment