mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Manually specify translations
This commit is contained in:
parent
ec60dccb7b
commit
7adb1cd504
@ -41,11 +41,11 @@ import { getLocales } from "expo-localization";
|
|||||||
import { Slot } from "expo-router";
|
import { Slot } from "expo-router";
|
||||||
import * as SplashScreen from "expo-splash-screen";
|
import * as SplashScreen from "expo-splash-screen";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import resourceToBackend from "i18next-resources-to-backend";
|
|
||||||
import "intl-pluralrules";
|
import "intl-pluralrules";
|
||||||
import { type ReactNode, useEffect, useState } from "react";
|
import { type ReactNode, useEffect, useState } from "react";
|
||||||
import { initReactI18next } from "react-i18next";
|
import { initReactI18next } from "react-i18next";
|
||||||
import { useColorScheme } from "react-native";
|
import { useColorScheme } from "react-native";
|
||||||
|
import resources from "../../../translations";
|
||||||
|
|
||||||
import NetInfo from "@react-native-community/netinfo";
|
import NetInfo from "@react-native-community/netinfo";
|
||||||
import { onlineManager } from "@tanstack/react-query";
|
import { onlineManager } from "@tanstack/react-query";
|
||||||
@ -72,16 +72,14 @@ const clientStorage = {
|
|||||||
|
|
||||||
export const clientPersister = createSyncStoragePersister({ storage: clientStorage });
|
export const clientPersister = createSyncStoragePersister({ storage: clientStorage });
|
||||||
|
|
||||||
i18next
|
i18next.use(initReactI18next).init({
|
||||||
.use(initReactI18next)
|
interpolation: {
|
||||||
.use(resourceToBackend((lang: string) => require(`../../../translations/${lang}.json`)))
|
escapeValue: false,
|
||||||
.init({
|
},
|
||||||
interpolation: {
|
fallbackLng: "en",
|
||||||
escapeValue: false,
|
lng: getLocales()[0].languageCode ?? "en",
|
||||||
},
|
resources,
|
||||||
fallbackLng: "en",
|
});
|
||||||
lng: getLocales()[0].languageCode ?? "en",
|
|
||||||
});
|
|
||||||
|
|
||||||
const NavigationThemeProvider = ({ children }: { children: ReactNode }) => {
|
const NavigationThemeProvider = ({ children }: { children: ReactNode }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
"expo-status-bar": "~1.12.1",
|
"expo-status-bar": "~1.12.1",
|
||||||
"expo-updates": "~0.25.14",
|
"expo-updates": "~0.25.14",
|
||||||
"i18next": "^23.11.4",
|
"i18next": "^23.11.4",
|
||||||
"i18next-resources-to-backend": "^1.2.1",
|
|
||||||
"intl-pluralrules": "^2.0.1",
|
"intl-pluralrules": "^2.0.1",
|
||||||
"moti": "^0.29.0",
|
"moti": "^0.29.0",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
"name": "web",
|
"name": "web",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"sideEffects": [
|
"sideEffects": ["./src/polyfill.ts"],
|
||||||
"./src/polyfill.ts"
|
|
||||||
],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
@ -22,6 +22,7 @@ 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, useMemo } from "react";
|
||||||
import { I18nextProvider } from "react-i18next";
|
import { I18nextProvider } from "react-i18next";
|
||||||
|
import resources from "../../../translations";
|
||||||
|
|
||||||
export const withTranslations = (
|
export const withTranslations = (
|
||||||
AppToTranslate: ComponentType<AppProps> & {
|
AppToTranslate: ComponentType<AppProps> & {
|
||||||
@ -33,6 +34,7 @@ export const withTranslations = (
|
|||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
},
|
},
|
||||||
|
resources,
|
||||||
};
|
};
|
||||||
|
|
||||||
const AppWithTranslations = (props: AppProps) => {
|
const AppWithTranslations = (props: AppProps) => {
|
||||||
@ -41,10 +43,9 @@ export const withTranslations = (
|
|||||||
i18next.init({
|
i18next.init({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
lng: props.pageProps.__lang,
|
lng: props.pageProps.__lang,
|
||||||
resources: props.pageProps.__resources,
|
|
||||||
});
|
});
|
||||||
return i18next;
|
return i18next;
|
||||||
}, [props.pageProps.__lang, props.pageProps.__resources]);
|
}, [props.pageProps.__lang]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<I18nextProvider i18n={li18n}>
|
<I18nextProvider i18n={li18n}>
|
||||||
@ -61,7 +62,6 @@ export const withTranslations = (
|
|||||||
fallbackLng: ctx.router.defaultLocale || "en",
|
fallbackLng: ctx.router.defaultLocale || "en",
|
||||||
});
|
});
|
||||||
props.pageProps.__lang = lng;
|
props.pageProps.__lang = lng;
|
||||||
// props.pageProps.__resources = resources;
|
|
||||||
return props;
|
return props;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,10 +14,7 @@
|
|||||||
"format": "biome format .",
|
"format": "biome format .",
|
||||||
"format:fix": "biome format . --write"
|
"format:fix": "biome format . --write"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": ["apps/*", "packages/*"],
|
||||||
"apps/*",
|
|
||||||
"packages/*"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "1.7.3",
|
"@biomejs/biome": "1.7.3",
|
||||||
"typescript": "5.4.5"
|
"typescript": "5.4.5"
|
||||||
|
17
front/translations/index.js
Normal file
17
front/translations/index.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import de from "./de";
|
||||||
|
import en from "./en";
|
||||||
|
import fr from "./fr";
|
||||||
|
import pl from "./pl";
|
||||||
|
import tr from "./tr";
|
||||||
|
import uk from "./uk";
|
||||||
|
import zh from "./zh";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
de: { translation: de },
|
||||||
|
en: { translation: en },
|
||||||
|
fr: { translation: fr },
|
||||||
|
pl: { translation: pl },
|
||||||
|
tr: { translation: tr },
|
||||||
|
uk: { translation: uk },
|
||||||
|
zh: { translation: zh },
|
||||||
|
};
|
@ -8822,15 +8822,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"i18next-resources-to-backend@npm:^1.2.1":
|
|
||||||
version: 1.2.1
|
|
||||||
resolution: "i18next-resources-to-backend@npm:1.2.1"
|
|
||||||
dependencies:
|
|
||||||
"@babel/runtime": ^7.23.2
|
|
||||||
checksum: a2f338c4eec8d5ba09846ae1abdd23afb72086f6395d6160c748d010c82f5c28c30133f6487f0fd3a65e710231d7750b324785f15cac4baf6d24b33227840341
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"i18next@npm:^23.11.4":
|
"i18next@npm:^23.11.4":
|
||||||
version: 23.11.4
|
version: 23.11.4
|
||||||
resolution: "i18next@npm:23.11.4"
|
resolution: "i18next@npm:23.11.4"
|
||||||
@ -10471,7 +10462,6 @@ __metadata:
|
|||||||
expo-status-bar: ~1.12.1
|
expo-status-bar: ~1.12.1
|
||||||
expo-updates: ~0.25.14
|
expo-updates: ~0.25.14
|
||||||
i18next: ^23.11.4
|
i18next: ^23.11.4
|
||||||
i18next-resources-to-backend: ^1.2.1
|
|
||||||
intl-pluralrules: ^2.0.1
|
intl-pluralrules: ^2.0.1
|
||||||
moti: ^0.29.0
|
moti: ^0.29.0
|
||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user