fixed language not found prompt

This commit is contained in:
Secretboy-SMR 2022-05-11 15:27:05 +08:00 committed by Melledy
parent 2cd1d32fbe
commit 6be39eafd2
2 changed files with 9 additions and 2 deletions

View File

@ -44,6 +44,13 @@ public final class LanguageCommand implements CommandHandler {
actualLangCode = languageInst.getLanguageCode();
Grasscutter.setLanguage(languageInst);
}
if (!langCode.equals(actualLangCode)) {
// I think there is no necessary to register this in language files
// since this will always be english
CommandHandler.sendMessage(sender, "currently, server does not have that language: " + langCode);
}
CommandHandler.sendMessage(sender, translate(sender, "commands.language.language_changed", actualLangCode));
}

View File

@ -125,23 +125,23 @@ public final class Language {
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
if (file == null) { // Provided fallback language.
Grasscutter.getLogger().warn("Failed to load language file: " + fileName + ", falling back to: " + fallback);
actualLanguageCode = fallbackLanguageCode;
if (cachedLanguages.containsKey(actualLanguageCode)) {
return new LanguageStreamDescription(actualLanguageCode, null);
}
file = Grasscutter.class.getResourceAsStream("/languages/" + fallback);
Grasscutter.getLogger().warn("Failed to load language file: " + fileName + ", falling back to: " + fallback);
}
if(file == null) { // Fallback the fallback language.
Grasscutter.getLogger().warn("Failed to load language file: " + fallback + ", falling back to: en-US.json");
actualLanguageCode = "en-US";
if (cachedLanguages.containsKey(actualLanguageCode)) {
return new LanguageStreamDescription(actualLanguageCode, null);
}
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)