From 0c5e69e1dab2b8cfc82bbf7a79abff8521a64f63 Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:24:53 -0700 Subject: [PATCH] fix: run without locales present (#4539) some code was hard-wired with locales having to be present. This is no longer the case now --- src/ui/egg-gacha-ui-handler.ts | 2 +- src/ui/starter-select-ui-handler.ts | 4 ++-- src/ui/test-dialogue-ui-handler.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui/egg-gacha-ui-handler.ts b/src/ui/egg-gacha-ui-handler.ts index b109eda5370..2eb1a100f38 100644 --- a/src/ui/egg-gacha-ui-handler.ts +++ b/src/ui/egg-gacha-ui-handler.ts @@ -217,7 +217,7 @@ export default class EggGachaUiHandler extends MessageUiHandler { { multiplier: multiplierOne, description: `25 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) } ]; - const resolvedLanguage = i18next.resolvedLanguage!; // TODO: is this bang correct? + const resolvedLanguage = i18next.resolvedLanguage ?? "en"; // TODO: is this bang correct? const pullOptionsText = pullOptions.map(option =>{ const desc = option.description.split(" "); if (desc[0].length < 2) { diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 03defdbdb5c..3ecc7da42e3 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -358,8 +358,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { setup() { const ui = this.getUi(); - const currentLanguage = i18next.resolvedLanguage!; // TODO: is this bang correct? - const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang))!; // TODO: is this bang correct? + const currentLanguage = i18next.resolvedLanguage ?? "en"; // TODO: is this bang correct? + const langSettingKey = Object.keys(languageSettings).find(lang => currentLanguage.includes(lang)) ?? "en"; // TODO: is this bang correct? const textSettings = languageSettings[langSettingKey]; this.starterSelectContainer = this.scene.add.container(0, -this.scene.game.canvas.height / 6); diff --git a/src/ui/test-dialogue-ui-handler.ts b/src/ui/test-dialogue-ui-handler.ts index 3f353bbc461..0acd9da193b 100644 --- a/src/ui/test-dialogue-ui-handler.ts +++ b/src/ui/test-dialogue-ui-handler.ts @@ -17,8 +17,8 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { setup() { super.setup(); - const flattenKeys = (object, topKey?: string, midleKey?: string[]): Array => { - return Object.keys(object).map((t, i) => { + const flattenKeys = (object?: any, topKey?: string, midleKey?: string[]): Array => { + return Object.keys(object ?? {}).map((t, i) => { const value = Object.values(object)[i]; if (typeof value === "object" && !isNullOrUndefined(value)) { // we check for not null or undefined here because if the language json file has a null key, the typeof will still be an object, but that object will be null, causing issues