Skip to content

Commit

Permalink
fix: if language doesn't exist, app crashing
Browse files Browse the repository at this point in the history
happening because `en-GB` doesn't exist in translations
  • Loading branch information
vixalien committed Apr 1, 2024
1 parent 2165ce2 commit 8048693
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions parsers/browsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}
}

Expand Down

0 comments on commit 8048693

Please sign in to comment.