Fix translations type safety

This commit is contained in:
Zoe Roux 2024-05-19 16:47:36 +02:00
parent 7adb1cd504
commit b453fb180c
No known key found for this signature in database
3 changed files with 4 additions and 32 deletions

View File

@ -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 (
<I18nextProvider i18n={li18n}>
@ -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;

View File

@ -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 };
}
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
import "i18next";
import type en from "../../../translations/en.json";
declare module "i18next" {
interface CustomTypeOptions {
returnNull: false;
resources: { translations: typeof en };
}
}