From b453fb180c17ddba527977cad3f5974569374c25 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 19 May 2024 16:47:36 +0200 Subject: [PATCH] Fix translations type safety --- front/apps/web/src/i18n.tsx | 5 ++-- .../i18n-d.ts => packages/ui/src/i18n-d.d.ts} | 2 +- front/packages/ui/src/i18n-d.ts | 29 ------------------- 3 files changed, 4 insertions(+), 32 deletions(-) rename front/{apps/web/src/i18n-d.ts => packages/ui/src/i18n-d.d.ts} (95%) delete mode 100644 front/packages/ui/src/i18n-d.ts diff --git a/front/apps/web/src/i18n.tsx b/front/apps/web/src/i18n.tsx index 60b87ac9..17f119ae 100644 --- a/front/apps/web/src/i18n.tsx +++ b/front/apps/web/src/i18n.tsx @@ -43,9 +43,10 @@ export const withTranslations = ( i18next.init({ ...commonOptions, lng: props.pageProps.__lang, + fallbackLng: "en", }); return i18next; - }, [props.pageProps.__lang]); + }, [props.pageProps.__lang, props.pageProps.__fallbackLng]); return ( @@ -59,7 +60,7 @@ export const withTranslations = ( await i18n.init({ ...commonOptions, lng, - fallbackLng: ctx.router.defaultLocale || "en", + fallbackLng: "en", }); props.pageProps.__lang = lng; return props; diff --git a/front/apps/web/src/i18n-d.ts b/front/packages/ui/src/i18n-d.d.ts similarity index 95% rename from front/apps/web/src/i18n-d.ts rename to front/packages/ui/src/i18n-d.d.ts index 46c3f118..4d963c6e 100644 --- a/front/apps/web/src/i18n-d.ts +++ b/front/packages/ui/src/i18n-d.d.ts @@ -24,6 +24,6 @@ import type en from "../../../translations/en.json"; declare module "i18next" { interface CustomTypeOptions { returnNull: false; - resources: { translations: typeof en }; + resources: { translation: typeof en }; } } diff --git a/front/packages/ui/src/i18n-d.ts b/front/packages/ui/src/i18n-d.ts deleted file mode 100644 index 46c3f118..00000000 --- a/front/packages/ui/src/i18n-d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Kyoo - A portable and vast media library solution. - * Copyright (c) Kyoo. - * - * See AUTHORS.md and LICENSE file in the project root for full license information. - * - * Kyoo is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * Kyoo is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Kyoo. If not, see . - */ - -import "i18next"; -import type en from "../../../translations/en.json"; - -declare module "i18next" { - interface CustomTypeOptions { - returnNull: false; - resources: { translations: typeof en }; - } -}