From a4ae4944aec7b2ff741f4308d381bf764351594d Mon Sep 17 00:00:00 2001 From: OMGDuke Date: Sat, 25 Feb 2023 23:47:07 +0000 Subject: [PATCH] handle unknown strings, in case a new proton medal type is added --- src/hooks/useTranslations.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hooks/useTranslations.ts b/src/hooks/useTranslations.ts index 911f8b4..962a1ca 100644 --- a/src/hooks/useTranslations.ts +++ b/src/hooks/useTranslations.ts @@ -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 + } } }