aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/index.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-28 16:21:47 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-28 16:21:47 +0100
commit2bae7c43764df5678fe2fc2e68be11ae95d85a41 (patch)
tree761f1283ace5681378b2a1d90fc05d8816e5eb41 /src/pages/index.tsx
parent341c256566f4e2301c0adeaaa7c6833070bf0e86 (diff)
fix: handle translation with lingui
The previous method was not working so I tried a different approach. Translation is loaded but I'm still getting warnings: * Plurals for locale undefined aren't loaded * Text content did not match I can't figure how to fix them...
Diffstat (limited to 'src/pages/index.tsx')
-rw-r--r--src/pages/index.tsx15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index bc89334..ae5fe4b 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,10 +1,10 @@
import type { ReactElement } from 'react';
-import { GetStaticProps } from 'next';
+import { GetStaticProps, GetStaticPropsContext } from 'next';
import Head from 'next/head';
import Layout from '@components/Layouts/Layout';
import { seo } from '@config/seo';
import { NextPageWithLayout } from '@ts/types/app';
-import { loadTranslation } from '@utils/helpers/i18n';
+import { defaultLocale, loadTranslation } from '@utils/helpers/i18n';
import HomePageContent from '@content/pages/homepage.mdx';
import { ButtonLink } from '@components/Buttons';
import styles from '@styles/pages/Home.module.scss';
@@ -137,14 +137,15 @@ Home.getLayout = function getLayout(page: ReactElement) {
return <Layout isHome={true}>{page}</Layout>;
};
-export const getStaticProps: GetStaticProps = async (ctx) => {
- const translation = await loadTranslation(
- ctx.locale!,
- process.env.NODE_ENV === 'production'
- );
+export const getStaticProps: GetStaticProps = async (
+ context: GetStaticPropsContext
+) => {
+ const { locale } = context;
+ const translation = await loadTranslation(locale || defaultLocale);
return {
props: {
+ locale,
translation,
},
};