From e1fe1cfc64c5c880d94a4a5950cddf673cdef1be Mon Sep 17 00:00:00 2001 From: "wkylin.w" Date: Thu, 14 Dec 2023 16:26:50 +0800 Subject: [PATCH] feat: i18next --- .vscode/settings.json | 2 +- package-lock.json | 40 +++++++++++++++++++++++++++++++++------- package.json | 1 + src/i18n/i18n.js | 11 ++--------- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 41af47e7..98e09186 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -88,7 +88,7 @@ ] }, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "cSpell.customDictionaries": { "custom-dictionary-workspace": { diff --git a/package-lock.json b/package-lock.json index 8695d515..8ff5f8fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "license": "MIT", "dependencies": { "@ant-design/cssinjs": "^1.18.0", + "@babel/plugin-proposal-object-rest-spread": "^7.20.7", "@loadable/component": "^5.15.3", "@react-spring/web": "^9.7.3", "@react-three/drei": "^9.89.3", @@ -617,7 +618,6 @@ "version": "7.22.5", "resolved": "https://registry.npmmirror.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -883,6 +883,25 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-proposal-object-rest-spread": { + "version": "7.20.7", + "resolved": "https://registry.npmmirror.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", + "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.", + "dependencies": { + "@babel/compat-data": "^7.20.5", + "@babel/helper-compilation-targets": "^7.20.7", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-transform-parameters": "^7.20.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-proposal-private-property-in-object": { "version": "7.21.0-placeholder-for-preset-env.2", "resolved": "https://registry.npmmirror.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", @@ -1094,7 +1113,6 @@ "version": "7.8.3", "resolved": "https://registry.npmmirror.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -1729,7 +1747,6 @@ "version": "7.23.3", "resolved": "https://registry.npmmirror.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.23.3.tgz", "integrity": "sha512-09lMt6UsUb3/34BbECKVbVwrT9bO6lILWln237z7sLaWnMsTi7Yc9fhX5DLpkJzAGfaReXI22wP41SZmnAA3Vw==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" }, @@ -43930,8 +43947,7 @@ "@babel/helper-plugin-utils": { "version": "7.22.5", "resolved": "https://registry.npmmirror.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", - "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", - "dev": true + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==" }, "@babel/helper-remap-async-to-generator": { "version": "7.22.20", @@ -44112,6 +44128,18 @@ "@babel/plugin-syntax-decorators": "^7.23.3" } }, + "@babel/plugin-proposal-object-rest-spread": { + "version": "7.20.7", + "resolved": "https://registry.npmmirror.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", + "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", + "requires": { + "@babel/compat-data": "^7.20.5", + "@babel/helper-compilation-targets": "^7.20.7", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-transform-parameters": "^7.20.7" + } + }, "@babel/plugin-proposal-private-property-in-object": { "version": "7.21.0-placeholder-for-preset-env.2", "resolved": "https://registry.npmmirror.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", @@ -44258,7 +44286,6 @@ "version": "7.8.3", "resolved": "https://registry.npmmirror.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -44662,7 +44689,6 @@ "version": "7.23.3", "resolved": "https://registry.npmmirror.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.23.3.tgz", "integrity": "sha512-09lMt6UsUb3/34BbECKVbVwrT9bO6lILWln237z7sLaWnMsTi7Yc9fhX5DLpkJzAGfaReXI22wP41SZmnAA3Vw==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.22.5" } diff --git a/package.json b/package.json index 51c00307..cc9f04d9 100644 --- a/package.json +++ b/package.json @@ -220,6 +220,7 @@ }, "dependencies": { "@ant-design/cssinjs": "^1.18.0", + "@babel/plugin-proposal-object-rest-spread": "^7.20.7", "@loadable/component": "^5.15.3", "@react-spring/web": "^9.7.3", "@react-three/drei": "^9.89.3", diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js index afa861ce..445f8fae 100644 --- a/src/i18n/i18n.js +++ b/src/i18n/i18n.js @@ -1,20 +1,13 @@ import i18n from 'i18next' -// import Backend from 'i18next-http-backend' import { initReactI18next } from 'react-i18next' import LanguageDetector from 'i18next-browser-languagedetector' -import translationInZh from '../locales/zh/translation.json' -import translationInEn from '../locales/en/translation.json' -// import translationInZh from '../locales/zh/translation' -// import translationInEn from '../locales/en/translation' +import translationInZh from '../locales/zh/translation' +import translationInEn from '../locales/en/translation' i18n - // .use(Backend) .use(LanguageDetector) .use(initReactI18next) .init({ - // backend: { - // loadPath: `${process.env.PUBLIC_URL}/locales/{{lng}}/{{ns}}.json`, - // }, resources: { en: { translation: translationInEn,