From a4cb75aaf06423babdf57fd070e008418f100217 Mon Sep 17 00:00:00 2001 From: Lee ByungHoon Date: Sat, 8 Jun 2024 23:15:53 +0900 Subject: [PATCH] [Bug] Fix to show current locale in setting (#1942) * [Bug] Fix to show current locale in setting * Add default value of lauguage option --- .../settings/settings-display-ui-handler.ts | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/ui/settings/settings-display-ui-handler.ts b/src/ui/settings/settings-display-ui-handler.ts index 9e61c2ba0b2..0aed0689388 100644 --- a/src/ui/settings/settings-display-ui-handler.ts +++ b/src/ui/settings/settings-display-ui-handler.ts @@ -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"; } }