Last active
August 16, 2021 20:24
-
-
Save florianmartens/bf4556bc80f5b22429740b26c12a0df0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import English from "../compiled-locales/en.json"; | |
import German from "../compiled-locales/de.json"; | |
function MyApp({ Component, pageProps }: AppProps) { | |
const { locale } = useRouter(); | |
const [shortLocale] = locale ? locale.split("-") : ["en"]; | |
const messages = useMemo(() => { | |
switch (shortLocale) { | |
case "de": | |
return German; | |
case "en": | |
return English; | |
default: | |
return English; | |
} | |
}, [shortLocale]); | |
return ( | |
<IntlProvider | |
locale={shortLocale} | |
messages={messages} | |
onError={() => null}> | |
<FormattedMessage defaultMessage="bla bla" /> | |
<Component {...pageProps} /> | |
</IntlProvider> | |
); | |
} | |
export default MyApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment