Skip to content

Commit

Permalink
fix(i18n): fix type issue at LanguageProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
devshred committed May 6, 2024
1 parent 9f34d66 commit 92406b1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type LanguageProviderProps = {
language: Language
children: ReactNode
}
type Messages = { [messageKey: string]: string | string[] }
type LanguageDictionary = { [languageKey: string]: Messages }

export const LanguageProvider: React.FC<LanguageProviderProps> = ({
language,
Expand All @@ -17,9 +19,7 @@ export const LanguageProvider: React.FC<LanguageProviderProps> = ({
const [currentLanguage, setCurrentLanguage] = useState<Language>(language)
const changeLanguage = (language: Language) => setCurrentLanguage(language)

const dictionary: {
[languageKey: string]: { [messageKey: string]: string }
} = { en, de }
const dictionary: LanguageDictionary = { en, de, }

const getMessage = (messageKey: string) => {
const message = dictionary[currentLanguage][messageKey]
Expand Down

0 comments on commit 92406b1

Please sign in to comment.