From 6be39eafd28d746b6ad10fa69b0a1ae66d11499e Mon Sep 17 00:00:00 2001 From: Secretboy-SMR Date: Wed, 11 May 2022 15:27:05 +0800 Subject: [PATCH] fixed language not found prompt --- .../emu/grasscutter/command/commands/LanguageCommand.java | 7 +++++++ src/main/java/emu/grasscutter/utils/Language.java | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java b/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java index 5966c6167..023b6a088 100644 --- a/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java @@ -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)); } diff --git a/src/main/java/emu/grasscutter/utils/Language.java b/src/main/java/emu/grasscutter/utils/Language.java index 4698606d7..094f7465f 100644 --- a/src/main/java/emu/grasscutter/utils/Language.java +++ b/src/main/java/emu/grasscutter/utils/Language.java @@ -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)