[Bug] Fix to show current locale in setting (#1942)

* [Bug] Fix to show current locale in setting

* Add default value of lauguage option
This commit is contained in:
Lee ByungHoon 2024-06-08 23:15:53 +09:00 committed by GitHub
parent bd5d16802a
commit a4cb75aaf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 43 additions and 1 deletions

View File

@ -2,7 +2,7 @@ import BattleScene from "../../battle-scene";
import { Mode } from "../ui";
"#app/inputs-controller.js";
import AbstractSettingsUiHandler from "./abstract-settings-ui-handler";
import { Setting, SettingType } from "#app/system/settings/settings";
import { Setting, SettingKeys, SettingType } from "#app/system/settings/settings";
export default class SettingsDisplayUiHandler extends AbstractSettingsUiHandler {
/**
@ -15,6 +15,48 @@ export default class SettingsDisplayUiHandler extends AbstractSettingsUiHandler
super(scene, mode);
this.title = "Display";
this.settings = Setting.filter(s => s.type === SettingType.DISPLAY);
/**
* Update to current language from default value.
* - default value is 'English'
*/
const languageIndex = this.settings.findIndex(s => s.key === SettingKeys.Language);
if (languageIndex >= 0) {
const currentLocale = localStorage.getItem("prLang");
switch (currentLocale) {
case "en":
this.settings[languageIndex].options[0] = "English";
break;
case "es":
this.settings[languageIndex].options[0] = "Español";
break;
case "it":
this.settings[languageIndex].options[0] = "Italiano";
break;
case "fr":
this.settings[languageIndex].options[0] = "Français";
break;
case "de":
this.settings[languageIndex].options[0] = "Deutsch";
break;
case "pt-BR":
this.settings[languageIndex].options[0] = "Português (BR)";
break;
case "zh-CN":
this.settings[languageIndex].options[0] = "简体中文";
break;
case "zh-TW":
this.settings[languageIndex].options[0] = "繁體中文";
break;
case "ko":
this.settings[languageIndex].options[0] = "한국어";
break;
default:
this.settings[languageIndex].options[0] = "English";
break;
}
}
this.localStorageKey = "settings";
}
}