mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-30 15:08:43 +00:00
Add warning for language fallback
This commit is contained in:
parent
1234a88c67
commit
392ce26e32
@ -16,7 +16,6 @@ public final class Config {
|
|||||||
public String KEY_FOLDER = "./keys/";
|
public String KEY_FOLDER = "./keys/";
|
||||||
public String SCRIPTS_FOLDER = "./resources/Scripts/";
|
public String SCRIPTS_FOLDER = "./resources/Scripts/";
|
||||||
public String PLUGINS_FOLDER = "./plugins/";
|
public String PLUGINS_FOLDER = "./plugins/";
|
||||||
public String LANGUAGE_FOLDER = "./languages/";
|
|
||||||
|
|
||||||
public ServerDebugMode DebugMode = ServerDebugMode.NONE; // ALL, MISSING, NONE
|
public ServerDebugMode DebugMode = ServerDebugMode.NONE; // ALL, MISSING, NONE
|
||||||
public ServerRunMode RunMode = ServerRunMode.HYBRID; // HYBRID, DISPATCH_ONLY, GAME_ONLY
|
public ServerRunMode RunMode = ServerRunMode.HYBRID; // HYBRID, DISPATCH_ONLY, GAME_ONLY
|
||||||
|
@ -19,7 +19,7 @@ public final class Language {
|
|||||||
* @return A language instance.
|
* @return A language instance.
|
||||||
*/
|
*/
|
||||||
public static Language getLanguage(String langCode) {
|
public static Language getLanguage(String langCode) {
|
||||||
return new Language(langCode + ".json", Grasscutter.getConfig().DefaultLanguage.toLanguageTag());
|
return new Language(langCode + ".json", Grasscutter.getConfig().DefaultLanguage.toLanguageTag() + ".json");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,10 +47,14 @@ public final class Language {
|
|||||||
@Nullable JsonObject languageData = null;
|
@Nullable JsonObject languageData = null;
|
||||||
|
|
||||||
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
|
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
|
||||||
if(file == null) // Provided fallback language.
|
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.
|
Grasscutter.getLogger().warn("Failed to load language file: " + fileName + ", falling back to: " + fallback);
|
||||||
|
}
|
||||||
|
if(file == null) { // Fallback the fallback language.
|
||||||
file = Grasscutter.class.getResourceAsStream("/languages/en-US.json");
|
file = Grasscutter.class.getResourceAsStream("/languages/en-US.json");
|
||||||
|
Grasscutter.getLogger().warn("Failed to load language file: " + fallback + ", falling back to: en-US.json");
|
||||||
|
}
|
||||||
if(file == null)
|
if(file == null)
|
||||||
throw new RuntimeException("Unable to load the primary, fallback, and 'en-US' language files.");
|
throw new RuntimeException("Unable to load the primary, fallback, and 'en-US' language files.");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user