mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 12:33:21 +08:00
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
This commit is contained in:
parent
7e3bfed003
commit
e3fd2eaa17
@ -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));
|
||||
|
@ -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.
|
||||
|
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user