mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -04:00
Fix i18n double init on web
This commit is contained in:
parent
f005f2022c
commit
261c97f97b
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
import i18next, { type InitOptions } from "i18next";
|
import i18next, { type InitOptions } from "i18next";
|
||||||
import type { AppContext, AppInitialProps, AppProps } from "next/app";
|
import type { AppContext, AppInitialProps, AppProps } from "next/app";
|
||||||
import { type ComponentType, useMemo } from "react";
|
import { type ComponentType, useState } from "react";
|
||||||
import { I18nextProvider } from "react-i18next";
|
import { I18nextProvider } from "react-i18next";
|
||||||
import resources from "../../../translations";
|
import resources from "../../../translations";
|
||||||
|
|
||||||
@ -40,14 +40,14 @@ export const withTranslations = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const AppWithTranslations = (props: AppProps) => {
|
const AppWithTranslations = (props: AppProps) => {
|
||||||
const li18n = useMemo(() => {
|
const [li18n] = useState(() => {
|
||||||
if (typeof window === "undefined") return i18n;
|
if (typeof window === "undefined") return i18n;
|
||||||
i18next.init({
|
i18next.init({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
lng: props.pageProps.__lang,
|
lng: props.pageProps.__lang,
|
||||||
});
|
});
|
||||||
return i18next;
|
return i18next;
|
||||||
}, [props.pageProps.__lang]);
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<I18nextProvider i18n={li18n}>
|
<I18nextProvider i18n={li18n}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user