Skip to content

Instantly share code, notes, and snippets.

@florianmartens
Last active August 16, 2021 20:24
Show Gist options
  • Save florianmartens/bf4556bc80f5b22429740b26c12a0df0 to your computer and use it in GitHub Desktop.
Save florianmartens/bf4556bc80f5b22429740b26c12a0df0 to your computer and use it in GitHub Desktop.
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