Commit e3fd2eaa authored by Secretboy-SMR's avatar Secretboy-SMR Committed by Melledy
Browse files

Removed invalid code in getLanguageFileDescription,When the language is not...

Removed invalid code in getLanguageFileDescription,When the language is not discovered, it will use the built-in language fallback mechanism to fall back,At the same time, we also fix the issue that using language in the server does not save the settings of the server side locale
parent 7e3bfed0
......@@ -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));
......
......@@ -118,10 +118,6 @@ public final class Language {
var fallback = fallbackLanguageCode + ".json";
String actualLanguageCode = languageCode;
if (cachedLanguages.containsKey(actualLanguageCode)) {
return new LanguageStreamDescription(actualLanguageCode, null);
}
InputStream file = Grasscutter.class.getResourceAsStream("/languages/" + fileName);
if (file == null) { // Provided fallback language.
......
......@@ -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": {
......
......@@ -191,6 +191,7 @@
"language": {
"current_language": "当前语言是: %s",
"language_changed": "语言切换至: %s",
"language_not_found": "目前服务端没有这种语言: %s",
"description": "显示或切换当前语言。"
},
"list": {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment