mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-08 10:44:20 -04:00
Auto switch between ssr and browser mode of translations
This commit is contained in:
parent
31c183ecf1
commit
be54eb11fe
@ -6,7 +6,11 @@ import { ThemeSelector } from "~/primitives/theme";
|
||||
import { createQueryClient } from "~/query";
|
||||
import { AccountProvider } from "./account-provider";
|
||||
import { ErrorConsumer, ErrorProvider } from "./error-provider";
|
||||
import { TranslationsProvider } from "./translations.ssr";
|
||||
|
||||
const { TranslationsProvider } =
|
||||
typeof window === "undefined"
|
||||
? await import("./translations.ssr")
|
||||
: await import("./translations");
|
||||
|
||||
const QueryProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [queryClient] = useState(() => createQueryClient());
|
||||
|
@ -12,6 +12,7 @@ export const supportedLanguages = readdirSync(
|
||||
export const TranslationsProvider = ({ children }: { children: ReactNode }) => {
|
||||
const val = useMemo(() => {
|
||||
const i18n = i18next.createInstance();
|
||||
// TODO: make a real language detector
|
||||
i18n.use(FsBackend).init<FsBackendOptions>({
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
|
@ -7,6 +7,7 @@ import { I18nextProvider } from "react-i18next";
|
||||
export const TranslationsProvider = ({ children }: { children: ReactNode }) => {
|
||||
const val = useMemo(() => {
|
||||
const i18n = i18next.createInstance();
|
||||
// TODO: use https://github.com/i18next/i18next-browser-languageDetector
|
||||
i18n.use(HttpApi).init<HttpBackendOptions>({
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
|
@ -11,6 +11,7 @@
|
||||
"noEmit": true,
|
||||
"module": "Preserve",
|
||||
"moduleResolution": "Bundler",
|
||||
"target": "ES2017",
|
||||
"preserveSymlinks": true,
|
||||
"skipLibCheck": true,
|
||||
"jsx": "react-jsx",
|
||||
|
Loading…
x
Reference in New Issue
Block a user