mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 22:03:03 +08:00
Fallback to the fallback fallback
This commit is contained in:
parent
09801a1845
commit
137ea1e294
@ -46,12 +46,15 @@ public final class Language {
|
|||||||
private Language(String fileName, String fallback) {
|
private Language(String fileName, String fallback) {
|
||||||
@Nullable JsonObject languageData = null;
|
@Nullable JsonObject languageData = null;
|
||||||
|
|
||||||
try {
|
|
||||||
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
|
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
|
||||||
if(file == null) {
|
if(file == null) // Provided fallback language.
|
||||||
file = Grasscutter.class.getResourceAsStream("/languages/" + fallback);
|
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);
|
languageData = Grasscutter.getGsonFactory().fromJson(Utils.readFromInputStream(file), JsonObject.class);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Grasscutter.getLogger().warn("Failed to load language file: " + fileName, exception);
|
Grasscutter.getLogger().warn("Failed to load language file: " + fileName, exception);
|
||||||
|
Loading…
Reference in New Issue
Block a user