Last active
August 12, 2020 18:40
-
-
Save ljmotta/170d9ce61765c9623c68d35d90e17181 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Context typed with your Dictionary, which will be used by your components | |
export const myI18nCtx React.createContext<I18nContextType<MyDictionary>>({} as any); | |
export function App(props: Props) { | |
// Fallback locale and respective dictionary | |
const myI18nDefaults = { locale: "en", dictionary: english }; | |
// All your dictionaries. The key of the Map object should follow the browser pattern | |
const myI18nDictionaries = new Map([ | |
["en", english], | |
["pt", portuguese] | |
]); | |
return ( | |
<I18nDictionariesProvider defaults={myI18nDefaults} dictionaries={myI18nDictionaries} ctx={myI18nCtx}> | |
<MyComponent /> | |
</I18nDictionariesProvider> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment