From 2665a0b43a340d0a840bc727881ec341c063a3fb Mon Sep 17 00:00:00 2001 From: zhangshu <70257536+Appolli9527@users.noreply.github.com> Date: Wed, 10 Apr 2024 00:59:00 +0800 Subject: [PATCH] init internationalization and route --- youtube_collection_web/package-lock.json | 30 +++++++++++++++++ youtube_collection_web/package.json | 2 ++ youtube_collection_web/src/App.js | 32 ++++++------------- .../src/assets/locales/en-US.json | 3 ++ .../src/assets/locales/resources.js | 16 ++++++++++ .../src/assets/locales/zh-CN.json | 3 ++ youtube_collection_web/src/components/Home.js | 13 ++++++-- .../src/components/Home1.js | 13 ++++++++ .../src/components/Login.js | 18 +++++++++++ youtube_collection_web/src/i18n.ts | 27 ++++++++++++++++ youtube_collection_web/src/index.js | 1 + 11 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 youtube_collection_web/src/assets/locales/en-US.json create mode 100644 youtube_collection_web/src/assets/locales/resources.js create mode 100644 youtube_collection_web/src/assets/locales/zh-CN.json create mode 100644 youtube_collection_web/src/components/Home1.js create mode 100644 youtube_collection_web/src/components/Login.js create mode 100644 youtube_collection_web/src/i18n.ts diff --git a/youtube_collection_web/package-lock.json b/youtube_collection_web/package-lock.json index 42070bb..bf2eff5 100644 --- a/youtube_collection_web/package-lock.json +++ b/youtube_collection_web/package-lock.json @@ -6824,6 +6824,14 @@ } } }, + "html-parse-stringify": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz", + "integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==", + "requires": { + "void-elements": "3.1.0" + } + }, "html-webpack-plugin": { "version": "5.6.0", "resolved": "https://registry.npmmirror.com/html-webpack-plugin/-/html-webpack-plugin-5.6.0.tgz", @@ -6942,6 +6950,14 @@ "resolved": "https://registry.npmmirror.com/human-signals/-/human-signals-2.1.0.tgz", "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" }, + "i18next": { + "version": "23.11.0", + "resolved": "https://registry.npmmirror.com/i18next/-/i18next-23.11.0.tgz", + "integrity": "sha512-VwFtlgy2LDbY0Qs6VfekIm6mv5/JmSJrtBf4aszl7Vby8+GcBlri0/7dkMZXmzTfiBMPUPBOmYCdQK7K4emkGQ==", + "requires": { + "@babel/runtime": "^7.23.2" + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -11283,6 +11299,15 @@ "resolved": "https://registry.npmmirror.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, + "react-i18next": { + "version": "14.1.0", + "resolved": "https://registry.npmmirror.com/react-i18next/-/react-i18next-14.1.0.tgz", + "integrity": "sha512-3KwX6LHpbvGQ+sBEntjV4sYW3Zovjjl3fpoHbUwSgFHf0uRBcbeCBLR5al6ikncI5+W0EFb71QXZmfop+J6NrQ==", + "requires": { + "@babel/runtime": "^7.23.9", + "html-parse-stringify": "^3.0.1" + } + }, "react-is": { "version": "16.13.1", "resolved": "https://registry.npmmirror.com/react-is/-/react-is-16.13.1.tgz", @@ -12971,6 +12996,11 @@ "resolved": "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, + "void-elements": { + "version": "3.1.0", + "resolved": "https://registry.npmmirror.com/void-elements/-/void-elements-3.1.0.tgz", + "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==" + }, "w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", diff --git a/youtube_collection_web/package.json b/youtube_collection_web/package.json index 5a8fb0e..374edd6 100644 --- a/youtube_collection_web/package.json +++ b/youtube_collection_web/package.json @@ -8,8 +8,10 @@ "@testing-library/user-event": "^13.5.0", "antd": "^5.16.1", "axios": "^1.6.8", + "i18next": "^23.11.0", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-i18next": "^14.1.0", "react-router-dom": "^6.22.3", "react-scripts": "5.0.1", "web-vitals": "^2.1.4" diff --git a/youtube_collection_web/src/App.js b/youtube_collection_web/src/App.js index 1340799..d7088e7 100644 --- a/youtube_collection_web/src/App.js +++ b/youtube_collection_web/src/App.js @@ -1,34 +1,20 @@ import './App.css'; -import { Link, Route, Routes, useNavigate } from 'react-router-dom'; +import { Route, Routes, Navigate } from 'react-router-dom'; import Home from './components/Home'; -import { Button } from 'antd'; +import Login from './components/Login.js'; +import Home1 from './components/Home1.js'; -const Categories = () => ( -
Browse items by category.
-Welcome to our homepage!
+{t('hello')}
+ + Home1 +Welcome to our homepage!
+