aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/sujet
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/sujet
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/sujet')
-rw-r--r--src/pages/sujet/[slug].tsx9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx
index 028131b..9947758 100644
--- a/src/pages/sujet/[slug].tsx
+++ b/src/pages/sujet/[slug].tsx
@@ -3,7 +3,7 @@ import PostPreview from '@components/PostPreview/PostPreview';
import { t } from '@lingui/macro';
import { NextPageWithLayout } from '@ts/types/app';
import { TopicProps, ThematicPreview } from '@ts/types/taxonomies';
-import { loadTranslation } from '@utils/helpers/i18n';
+import { defaultLocale, loadTranslation } from '@utils/helpers/i18n';
import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next';
import { ParsedUrlQuery } from 'querystring';
import styles from '@styles/pages/Page.module.scss';
@@ -151,10 +151,8 @@ interface PostParams extends ParsedUrlQuery {
export const getStaticProps: GetStaticProps = async (
context: GetStaticPropsContext
) => {
- const translation = await loadTranslation(
- context.locale!,
- process.env.NODE_ENV === 'production'
- );
+ const { locale } = context;
+ const translation = await loadTranslation(locale || defaultLocale);
const { slug } = context.params as PostParams;
const topic = await getTopicBySlug(slug);
const breadcrumbTitle = topic.title;
@@ -162,6 +160,7 @@ export const getStaticProps: GetStaticProps = async (
return {
props: {
breadcrumbTitle,
+ locale,
topic,
translation,
},