mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-01-07 20:50:28 -05:00
26 lines
794 B
TypeScript
26 lines
794 B
TypeScript
import i18next from "i18next";
|
|
import { type ReactNode, useMemo } from "react";
|
|
import { I18nextProvider } from "react-i18next";
|
|
import { resources, supportedLanguages } from "./translations.compile";
|
|
import { setServerData } from "~/utils";
|
|
|
|
export const TranslationsProvider = ({ children }: { children: ReactNode }) => {
|
|
const val = useMemo(() => {
|
|
const i18n = i18next.createInstance();
|
|
i18n.init({
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
returnEmptyString: false,
|
|
fallbackLng: "en",
|
|
load: "currentOnly",
|
|
supportedLngs: supportedLanguages,
|
|
resources: resources,
|
|
});
|
|
// store data for the browser
|
|
setServerData("translations", i18n.services.resourceStore.data);
|
|
return i18n;
|
|
}, []);
|
|
return <I18nextProvider i18n={val}>{children}</I18nextProvider>;
|
|
};
|