From 6a6c8f0fd91a5c39c182062f6905aaad79cd443e Mon Sep 17 00:00:00 2001 From: torranx Date: Tue, 14 May 2024 11:02:09 +0800 Subject: [PATCH] return boolean from changing locale --- src/system/settings.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/system/settings.ts b/src/system/settings.ts index 08f9de0f8..b361948b8 100644 --- a/src/system/settings.ts +++ b/src/system/settings.ts @@ -178,11 +178,17 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer) scene.ui.revertMode(); (scene.ui.getHandler() as SettingsUiHandler).setOptionCursor(Object.values(Setting).indexOf(Setting.Language), 0, true); }; - const changeLocaleHandler = (locale: string) => { - i18next.changeLanguage(locale); - localStorage.setItem('prLang', locale); - cancelHandler(); - scene.reset(true, false, true); + const changeLocaleHandler = (locale: string): boolean => { + try { + i18next.changeLanguage(locale); + localStorage.setItem('prLang', locale); + cancelHandler(); + scene.reset(true, false, true); + return true; + } catch (error) { + console.error('Error changing locale:', error); + return false; + } }; scene.ui.setOverlayMode(Mode.OPTION_SELECT, { options: [