diff --git a/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java b/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java index 023b6a088..4783af0cc 100644 --- a/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/LanguageCommand.java @@ -31,24 +31,24 @@ public final class LanguageCommand implements CommandHandler { } String langCode = args.get(0); - String actualLangCode = null; + + var languageInst = Grasscutter.getLanguage(langCode); + var actualLangCode = languageInst.getLanguageCode(); + var locale = Locale.forLanguageTag(actualLangCode); if (sender != null) { - var locale = Locale.forLanguageTag(langCode); - actualLangCode = Utils.getLanguageCode(locale); var account = sender.getAccount(); account.setLocale(locale); account.save(); } else { - var languageInst = Grasscutter.getLanguage(langCode); - actualLangCode = languageInst.getLanguageCode(); Grasscutter.setLanguage(languageInst); + var config = Grasscutter.getConfig(); + config.language.language = locale; + Grasscutter.saveConfig(config); } 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_not_found", 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 094f7465f..3789f594a 100644 --- a/src/main/java/emu/grasscutter/utils/Language.java +++ b/src/main/java/emu/grasscutter/utils/Language.java @@ -116,12 +116,8 @@ public final class Language { private static LanguageStreamDescription getLanguageFileDescription(String languageCode, String fallbackLanguageCode) { var fileName = languageCode + ".json"; var fallback = fallbackLanguageCode + ".json"; - - String actualLanguageCode = languageCode; - if (cachedLanguages.containsKey(actualLanguageCode)) { - return new LanguageStreamDescription(actualLanguageCode, null); - } + String actualLanguageCode = languageCode; InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName); if (file == null) { // Provided fallback language. diff --git a/src/main/resources/languages/en-US.json b/src/main/resources/languages/en-US.json index 893f490af..c9c3c0c70 100644 --- a/src/main/resources/languages/en-US.json +++ b/src/main/resources/languages/en-US.json @@ -191,6 +191,7 @@ "language": { "current_language": "current language is %s", "language_changed": "language changed to %s", + "language_not_found": "currently, server does not have that language: %s", "description": "display or change current language" }, "list": { diff --git a/src/main/resources/languages/zh-CN.json b/src/main/resources/languages/zh-CN.json index 8d5b35137..2f9663f4f 100644 --- a/src/main/resources/languages/zh-CN.json +++ b/src/main/resources/languages/zh-CN.json @@ -191,6 +191,7 @@ "language": { "current_language": "当前语言是: %s", "language_changed": "语言切换至: %s", + "language_not_found": "目前服务端没有这种语言: %s", "description": "显示或切换当前语言。" }, "list": {