aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/404.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/404.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/404.tsx')
-rw-r--r--src/pages/404.tsx10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/pages/404.tsx b/src/pages/404.tsx
index 2c20578..5ba7b95 100644
--- a/src/pages/404.tsx
+++ b/src/pages/404.tsx
@@ -3,7 +3,7 @@ import PostHeader from '@components/PostHeader/PostHeader';
import { seo } from '@config/seo';
import { t, Trans } from '@lingui/macro';
import { NextPageWithLayout } from '@ts/types/app';
-import { loadTranslation } from '@utils/helpers/i18n';
+import { defaultLocale, loadTranslation } from '@utils/helpers/i18n';
import { GetStaticProps, GetStaticPropsContext } from 'next';
import Head from 'next/head';
import Link from 'next/link';
@@ -38,16 +38,14 @@ error404.getLayout = getLayout;
export const getStaticProps: GetStaticProps = async (
context: GetStaticPropsContext
) => {
- const translation = await loadTranslation(
- context.locale!,
- process.env.NODE_ENV === 'production'
- );
-
const breadcrumbTitle = t`Error`;
+ const { locale } = context;
+ const translation = await loadTranslation(locale || defaultLocale);
return {
props: {
breadcrumbTitle,
+ locale,
translation,
},
};