return boolean from changing locale (#848)

This commit is contained in:
Adrian Torrano 2024-05-20 02:25:24 +08:00 committed by GitHub
parent 840dba79cc
commit a561e41634
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 5 deletions

View File

@ -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: [