international languages support

This commit is contained in:
CalebChen768 2024-03-18 23:58:51 +08:00
parent c1ab05c46c
commit 67a4f27b8d
8 changed files with 1368 additions and 930 deletions

View File

@ -4,7 +4,7 @@
import 'react-native';
import React from 'react';
import App from '../App';
import App from '../src/App.tsx';
// Note: import explicitly to use the types shipped with jest.
import {it} from '@jest/globals';

View File

@ -3,7 +3,8 @@
*/
import {AppRegistry} from 'react-native';
import App from './App';
import App from './src/App';
import {name as appName} from './app.json';
import 'react-native-gesture-handler';
AppRegistry.registerComponent(appName, () => App);

View File

@ -944,6 +944,10 @@ PODS:
- React-Mapbuffer (0.73.6):
- glog
- React-debug
- react-native-safe-area-context (4.9.0):
- React-Core
- react-native-sqlite-storage (6.0.1):
- React-Core
- React-nativeconfig (0.73.6)
- React-NativeModulesApple (0.73.6):
- glog
@ -1111,6 +1115,18 @@ PODS:
- React-jsi (= 0.73.6)
- React-logger (= 0.73.6)
- React-perflogger (= 0.73.6)
- RNGestureHandler (2.15.0):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- RNScreens (3.29.0):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- RNVectorIcons (10.0.3):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- SocketRocket (0.6.1)
- Yoga (1.14.0)
@ -1167,6 +1183,8 @@ DEPENDENCIES:
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector-modern`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-sqlite-storage (from `../node_modules/react-native-sqlite-storage`)
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
@ -1187,6 +1205,9 @@ DEPENDENCIES:
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
SPEC REPOS:
@ -1261,6 +1282,10 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/logger"
React-Mapbuffer:
:path: "../node_modules/react-native/ReactCommon"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-sqlite-storage:
:path: "../node_modules/react-native-sqlite-storage"
React-nativeconfig:
:path: "../node_modules/react-native/ReactCommon"
React-NativeModulesApple:
@ -1301,6 +1326,12 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/react/utils"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNScreens:
:path: "../node_modules/react-native-screens"
RNVectorIcons:
:path: "../node_modules/react-native-vector-icons"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"
@ -1344,6 +1375,8 @@ SPEC CHECKSUMS:
React-jsinspector: 85583ef014ce53d731a98c66a0e24496f7a83066
React-logger: 3eb80a977f0d9669468ef641a5e1fabbc50a09ec
React-Mapbuffer: 84ea43c6c6232049135b1550b8c60b2faac19fab
react-native-safe-area-context: b97eb6f9e3b7f437806c2ce5983f479f8eb5de4b
react-native-sqlite-storage: f6d515e1c446d1e6d026aa5352908a25d4de3261
React-nativeconfig: b4d4e9901d4cabb57be63053fd2aa6086eb3c85f
React-NativeModulesApple: cd26e56d56350e123da0c1e3e4c76cb58a05e1ee
React-perflogger: 5f49905de275bac07ac7ea7f575a70611fa988f2
@ -1364,9 +1397,12 @@ SPEC CHECKSUMS:
React-runtimescheduler: 9636eee762c699ca7c85751a359101797e4c8b3b
React-utils: d16c1d2251c088ad817996621947d0ac8167b46c
ReactCommon: 2aa35648354bd4c4665b9a5084a7d37097b89c10
RNGestureHandler: 67fb54b3e6ca338a8044e85cd6f340265aa41091
RNScreens: 17e2f657f1b09a71ec3c821368a04acbb7ebcb46
RNVectorIcons: 73ab573085f65a572d3b6233e68996d4707fd505
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: d17d2cc8105eed528474683b42e2ea310e1daf61
Yoga: 805bf71192903b20fc14babe48080582fee65a80
PODFILE CHECKSUM: 29407bd75db4abdbd07d3a8c1b06fc5c12f802b3
COCOAPODS: 1.14.3
COCOAPODS: 1.15.2

View File

@ -10,8 +10,20 @@
"test": "jest"
},
"dependencies": {
"@react-navigation/bottom-tabs": "^6.5.19",
"@react-navigation/native": "^6.1.16",
"@react-navigation/stack": "^6.3.28",
"i18next": "^23.10.1",
"i18next-browser-languagedetector": "^7.2.0",
"i18next-http-backend": "^2.5.0",
"react": "18.2.0",
"react-native": "0.73.6"
"react-i18next": "^14.1.0",
"react-native": "0.73.6",
"react-native-gesture-handler": "^2.15.0",
"react-native-safe-area-context": "^4.9.0",
"react-native-screens": "^3.29.0",
"react-native-sqlite-storage": "^6.0.1",
"react-native-vector-icons": "^10.0.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
@ -22,6 +34,7 @@
"@react-native/metro-config": "0.73.5",
"@react-native/typescript-config": "0.73.1",
"@types/react": "^18.2.6",
"@types/react-native-vector-icons": "^6.4.18",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",

20
src/i18n/i18n.js Normal file
View File

@ -0,0 +1,20 @@
import i18n from 'i18next';
import {initReactI18next} from 'react-i18next';
import en from './locales/en.json';
import zh from './locales/zh.json';
i18n
.use(initReactI18next) // 将 i18next 传递给 react-i18next
.init({
resources: {
en: {translation: en},
zh: {translation: zh},
},
lng: 'en', // 默认语言
fallbackLng: 'en',
interpolation: {
escapeValue: false,
},
});
export default i18n;

8
src/i18n/locales/en.json Normal file
View File

@ -0,0 +1,8 @@
{
"welcome": "Welcome to MyAccountApp",
"login": "Log In",
"Overview": "Overview",
"Subscription": "Subscription",
"Saving": "Saving",
"Profile": "Profile"
}

8
src/i18n/locales/zh.json Normal file
View File

@ -0,0 +1,8 @@
{
"welcome": "欢迎使用 MyAccountApp",
"login": "登录",
"Overview": "概览",
"Subscription": "订阅",
"Saving": "存钱",
"Profile": "我的"
}

2202
yarn.lock

File diff suppressed because it is too large Load Diff