Add i18n translations and update tsconfig.json

This commit is contained in:
smallstone 2023-12-20 18:25:32 +08:00
parent 23ecbf6cba
commit 790152b8c3
6 changed files with 31 additions and 41 deletions

3
src/views/i18n/en.json Normal file
View File

@ -0,0 +1,3 @@
{
"Delete message": "Delete message"
}

View File

@ -1,16 +1,21 @@
import i18n from "i18next"; import i18n from "i18next";
import { initReactI18next } from "react-i18next"; import { initReactI18next } from "react-i18next";
import enTranslations from "./en.json";
import zhTranslations from "./zh.json";
console.log("enTranslations: ", enTranslations);
console.log("zhTranslations 233: ", zhTranslations);
i18n.use(initReactI18next).init({ i18n.use(initReactI18next).init({
resources: { resources: {
en: { en: {
translation: { translation: {
"Delete message": "Delete message", ...enTranslations,
}, },
}, },
zh: { zh: {
translation: { translation: {
"Delete message": "删除消息", ...zhTranslations,
}, },
}, },
}, },

3
src/views/i18n/zh.json Normal file
View File

@ -0,0 +1,3 @@
{
"Delete message": "11删除消息"
}

View File

@ -1,26 +1,19 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "commonjs", "resolveJsonModule": true,
"target": "ES2020", "esModuleInterop": true,
"lib": [ "module": "commonjs",
"ES2020", "target": "ES2020",
"es6", "lib": ["ES2020", "es6", "dom"],
"dom" "outDir": "./dist",
], "sourceMap": true,
"outDir": "./dist", "rootDir": "src",
"sourceMap": true, "strict": true,
"rootDir": "src", "jsx": "react",
"strict": true, "noImplicitAny": false,
"jsx": "react", "paths": {
"esModuleInterop": true, "@/*": ["./src/*"]
"noImplicitAny": false, }
"paths": { },
"@/*": [ "exclude": ["test"]
"./src/*"
]
}
},
"exclude": [
"test"
]
} }

View File

@ -1,9 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "out-test",
"skipLibCheck": true
},
"include": ["src/**/*.ts", "test/**/*.ts"]
}

View File

@ -72,11 +72,6 @@ const webviewConfig = {
], ],
include: /views/, include: /views/,
}, },
{
test: /\.json$/i,
use: "json-loader",
type: "asset/source",
},
{ {
test: /\.(png|jpg|jpeg|gif|svg)$/, // 匹配文件类型 test: /\.(png|jpg|jpeg|gif|svg)$/, // 匹配文件类型
use: [ use: [