Skip to content

Commit

Permalink
handle unknown strings, in case a new proton medal type is added
Browse files Browse the repository at this point in the history
  • Loading branch information
OMGDuke committed Feb 25, 2023
1 parent 45fcfb8 commit a4ae494
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/hooks/useTranslations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ function getCurrentLanguage(): keyof typeof languages {
function useTranslations() {
const [lang] = useState(getCurrentLanguage())
return function (key: keyof (typeof languages)['en']): string {
const stringTranslation = languages[lang]?.[key]
return stringTranslation?.length ? stringTranslation : languages.en?.[key]
if (languages[lang]?.[key]?.length) {
return languages[lang]?.[key]
} else if (languages.en?.[key]?.length) {
return languages.en?.[key]
} else {
return key
}
}
}

Expand Down

0 comments on commit a4ae494

Please sign in to comment.