From 80486930149c0960b517d54acbc412879250ea27 Mon Sep 17 00:00:00 2001 From: Angelo Verlain Date: Mon, 1 Apr 2024 20:34:38 +0200 Subject: [PATCH] fix: if language doesn't exist, app crashing happening because `en-GB` doesn't exist in translations --- parsers/browsing.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/parsers/browsing.ts b/parsers/browsing.ts index 98fa114..94f69ca 100644 --- a/parsers/browsing.ts +++ b/parsers/browsing.ts @@ -830,7 +830,7 @@ type Translatable = keyof typeof STRINGS[keyof typeof STRINGS]; export function _(id: Translatable) { const result = STRINGS[get_option("language") as keyof typeof STRINGS]; - return result[id] ?? id; + return result?.[id] ?? id; } export function __(value: string) { @@ -839,9 +839,11 @@ export function __(value: string) { const result = STRINGS[get_option("language") as keyof typeof STRINGS]; - for (const key in result) { - if (result[key as Translatable] === value) { - return key as Translatable; + if (result) { + for (const key in result) { + if (result[key as Translatable] === value) { + return key as Translatable; + } } }