aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/_app.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-28 18:19:24 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-29 19:02:57 +0100
commit47b854de26dea24e7838fd0804df103dee99635f (patch)
tree28ceab6a0a127bab9024bb7e6997f9db73bd13d6 /src/pages/_app.tsx
parent67ce6cc19cbfdf9692dc785d2fc88ecee4ed500c (diff)
chore(i18n): replace i18n provider and helpers
Diffstat (limited to 'src/pages/_app.tsx')
-rw-r--r--src/pages/_app.tsx26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index db021f9..ec97ff7 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -1,23 +1,21 @@
-import { useEffect } from 'react';
-import { i18n } from '@lingui/core';
-import { I18nProvider } from '@lingui/react';
+import { config } from '@config/website';
import { AppPropsWithLayout } from '@ts/types/app';
-import { activateLocale, defaultLocale, initLingui } from '@utils/helpers/i18n';
-import '../styles/globals.scss';
import { ThemeProvider } from 'next-themes';
-
-initLingui(defaultLocale);
+import { useRouter } from 'next/router';
+import { IntlProvider } from 'react-intl';
+import '../styles/globals.scss';
const MyApp = ({ Component, pageProps }: AppPropsWithLayout) => {
- const locale: string = pageProps.locale || defaultLocale;
-
- useEffect(() => {
- activateLocale(locale, pageProps.translation);
- });
+ const { locale, defaultLocale } = useRouter();
+ const appLocale: string = locale || config.locales.defaultLocale;
const getLayout = Component.getLayout ?? ((page) => page);
return (
- <I18nProvider i18n={i18n}>
+ <IntlProvider
+ locale={appLocale}
+ defaultLocale={defaultLocale}
+ messages={pageProps.translation}
+ >
<ThemeProvider
defaultTheme="system"
enableColorScheme={true}
@@ -25,7 +23,7 @@ const MyApp = ({ Component, pageProps }: AppPropsWithLayout) => {
>
{getLayout(<Component {...pageProps} />)}
</ThemeProvider>
- </I18nProvider>
+ </IntlProvider>
);
};