mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-08 18:54:22 -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 { createQueryClient } from "~/query";
|
||||||
import { AccountProvider } from "./account-provider";
|
import { AccountProvider } from "./account-provider";
|
||||||
import { ErrorConsumer, ErrorProvider } from "./error-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 QueryProvider = ({ children }: { children: ReactNode }) => {
|
||||||
const [queryClient] = useState(() => createQueryClient());
|
const [queryClient] = useState(() => createQueryClient());
|
||||||
|
@ -12,6 +12,7 @@ export const supportedLanguages = readdirSync(
|
|||||||
export const TranslationsProvider = ({ children }: { children: ReactNode }) => {
|
export const TranslationsProvider = ({ children }: { children: ReactNode }) => {
|
||||||
const val = useMemo(() => {
|
const val = useMemo(() => {
|
||||||
const i18n = i18next.createInstance();
|
const i18n = i18next.createInstance();
|
||||||
|
// TODO: make a real language detector
|
||||||
i18n.use(FsBackend).init<FsBackendOptions>({
|
i18n.use(FsBackend).init<FsBackendOptions>({
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
|
@ -7,6 +7,7 @@ import { I18nextProvider } from "react-i18next";
|
|||||||
export const TranslationsProvider = ({ children }: { children: ReactNode }) => {
|
export const TranslationsProvider = ({ children }: { children: ReactNode }) => {
|
||||||
const val = useMemo(() => {
|
const val = useMemo(() => {
|
||||||
const i18n = i18next.createInstance();
|
const i18n = i18next.createInstance();
|
||||||
|
// TODO: use https://github.com/i18next/i18next-browser-languageDetector
|
||||||
i18n.use(HttpApi).init<HttpBackendOptions>({
|
i18n.use(HttpApi).init<HttpBackendOptions>({
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"module": "Preserve",
|
"module": "Preserve",
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
|
"target": "ES2017",
|
||||||
"preserveSymlinks": true,
|
"preserveSymlinks": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user