diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-28 16:21:47 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-28 16:21:47 +0100 |
| commit | 2bae7c43764df5678fe2fc2e68be11ae95d85a41 (patch) | |
| tree | 761f1283ace5681378b2a1d90fc05d8816e5eb41 /src/pages/cv.tsx | |
| parent | 341c256566f4e2301c0adeaaa7c6833070bf0e86 (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/cv.tsx')
| -rw-r--r-- | src/pages/cv.tsx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/pages/cv.tsx b/src/pages/cv.tsx index 47093c4..85bddd6 100644 --- a/src/pages/cv.tsx +++ b/src/pages/cv.tsx @@ -1,7 +1,6 @@ import { getLayout } from '@components/Layouts/Layout'; import { seo } from '@config/seo'; import { NextPageWithLayout } from '@ts/types/app'; -import { loadTranslation } from '@utils/helpers/i18n'; import { GetStaticProps, GetStaticPropsContext } from 'next'; import Head from 'next/head'; import CVContent, { intro, meta, pdf, image } from '@content/pages/cv.mdx'; @@ -14,6 +13,7 @@ import Sidebar from '@components/Sidebar/Sidebar'; import { AboutPage, Graph, WebPage } from 'schema-dts'; import { config } from '@config/website'; import { useRouter } from 'next/router'; +import { defaultLocale, loadTranslation } from '@utils/helpers/i18n'; const CV: NextPageWithLayout = () => { const router = useRouter(); @@ -111,15 +111,14 @@ CV.getLayout = getLayout; export const getStaticProps: GetStaticProps = async ( context: GetStaticPropsContext ) => { - const translation = await loadTranslation( - context.locale!, - process.env.NODE_ENV === 'production' - ); const breadcrumbTitle = meta.title; + const { locale } = context; + const translation = await loadTranslation(locale || defaultLocale); return { props: { breadcrumbTitle, + locale, translation, }, }; |
