From bb4589a3efab76f327d56631b6a7354542a23b7b Mon Sep 17 00:00:00 2001 From: hanbingleixue Date: Tue, 25 Jun 2024 14:28:56 +0800 Subject: [PATCH] Add the ability of front-end internationalization Signed-off-by: hanbingleixue --- .../main/webapp/frontend/package-lock.json | 91 ++++ .../src/main/webapp/frontend/package.json | 1 + .../src/main/webapp/frontend/src/App.vue | 10 +- .../src/components/layouts/BaseHeader.vue | 41 +- .../webapp/frontend/src/composables/config.ts | 69 ++- .../frontend/src/composables/translations.ts | 465 ++++++++++++++++++ .../src/main/webapp/frontend/src/main.ts | 13 +- .../webapp/frontend/src/views/ConfigInfo.vue | 241 +++++---- .../webapp/frontend/src/views/ConfigView.vue | 78 +-- .../frontend/src/views/EventsConfigView.vue | 152 +++--- .../webapp/frontend/src/views/EventsView.vue | 439 ++++++++++------- .../frontend/src/views/InstancesView.vue | 202 ++++---- 12 files changed, 1282 insertions(+), 520 deletions(-) create mode 100644 sermant-backend/src/main/webapp/frontend/src/composables/translations.ts diff --git a/sermant-backend/src/main/webapp/frontend/package-lock.json b/sermant-backend/src/main/webapp/frontend/package-lock.json index e62def19fe..cfd447dbc9 100644 --- a/sermant-backend/src/main/webapp/frontend/package-lock.json +++ b/sermant-backend/src/main/webapp/frontend/package-lock.json @@ -15,6 +15,7 @@ "moment": "^2.29.4", "qs": "^6.11.1", "vue": "^3.2.36", + "vue-i18n": "^9.13.1", "vue-router": "^4.1.6" }, "devDependencies": { @@ -520,6 +521,44 @@ "local-pkg": "^0.4.3" } }, + "node_modules/@intlify/core-base": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/@intlify/core-base/-/core-base-9.13.1.tgz", + "integrity": "sha512-+bcQRkJO9pcX8d0gel9ZNfrzU22sZFSA0WVhfXrf5jdJOS24a+Bp8pozuS9sBI9Hk/tGz83pgKfmqcn/Ci7/8w==", + "dependencies": { + "@intlify/message-compiler": "9.13.1", + "@intlify/shared": "9.13.1" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/message-compiler": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/@intlify/message-compiler/-/message-compiler-9.13.1.tgz", + "integrity": "sha512-SKsVa4ajYGBVm7sHMXd5qX70O2XXjm55zdZB3VeMFCvQyvLew/dLvq3MqnaIsTMF1VkkOb9Ttr6tHcMlyPDL9w==", + "dependencies": { + "@intlify/shared": "9.13.1", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": ">= 16" + } + }, + "node_modules/@intlify/shared": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/@intlify/shared/-/shared-9.13.1.tgz", + "integrity": "sha512-u3b6BKGhE6j/JeRU6C/RL2FgyJfy6LakbtfeVF8fJXURpZZTzfh3e05J0bu0XPw447Q6/WUp3C4ajv4TMS4YsQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -3966,6 +4005,25 @@ "@vue/shared": "3.2.47" } }, + "node_modules/vue-i18n": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/vue-i18n/-/vue-i18n-9.13.1.tgz", + "integrity": "sha512-mh0GIxx0wPtPlcB1q4k277y0iKgo25xmDPWioVVYanjPufDBpvu5ySTjP5wOrSvlYQ2m1xI+CFhGdauv/61uQg==", + "dependencies": { + "@intlify/core-base": "9.13.1", + "@intlify/shared": "9.13.1", + "@vue/devtools-api": "^6.5.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, "node_modules/vue-router": { "version": "4.1.6", "resolved": "https://repo.huaweicloud.com/repository/npm/vue-router/-/vue-router-4.1.6.tgz", @@ -4471,6 +4529,29 @@ "local-pkg": "^0.4.3" } }, + "@intlify/core-base": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/@intlify/core-base/-/core-base-9.13.1.tgz", + "integrity": "sha512-+bcQRkJO9pcX8d0gel9ZNfrzU22sZFSA0WVhfXrf5jdJOS24a+Bp8pozuS9sBI9Hk/tGz83pgKfmqcn/Ci7/8w==", + "requires": { + "@intlify/message-compiler": "9.13.1", + "@intlify/shared": "9.13.1" + } + }, + "@intlify/message-compiler": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/@intlify/message-compiler/-/message-compiler-9.13.1.tgz", + "integrity": "sha512-SKsVa4ajYGBVm7sHMXd5qX70O2XXjm55zdZB3VeMFCvQyvLew/dLvq3MqnaIsTMF1VkkOb9Ttr6tHcMlyPDL9w==", + "requires": { + "@intlify/shared": "9.13.1", + "source-map-js": "^1.0.2" + } + }, + "@intlify/shared": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/@intlify/shared/-/shared-9.13.1.tgz", + "integrity": "sha512-u3b6BKGhE6j/JeRU6C/RL2FgyJfy6LakbtfeVF8fJXURpZZTzfh3e05J0bu0XPw447Q6/WUp3C4ajv4TMS4YsQ==" + }, "@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -6813,6 +6894,16 @@ "@vue/shared": "3.2.47" } }, + "vue-i18n": { + "version": "9.13.1", + "resolved": "https://r.cnpmjs.org/vue-i18n/-/vue-i18n-9.13.1.tgz", + "integrity": "sha512-mh0GIxx0wPtPlcB1q4k277y0iKgo25xmDPWioVVYanjPufDBpvu5ySTjP5wOrSvlYQ2m1xI+CFhGdauv/61uQg==", + "requires": { + "@intlify/core-base": "9.13.1", + "@intlify/shared": "9.13.1", + "@vue/devtools-api": "^6.5.0" + } + }, "vue-router": { "version": "4.1.6", "resolved": "https://repo.huaweicloud.com/repository/npm/vue-router/-/vue-router-4.1.6.tgz", diff --git a/sermant-backend/src/main/webapp/frontend/package.json b/sermant-backend/src/main/webapp/frontend/package.json index 4d725c6f9a..45971c4302 100644 --- a/sermant-backend/src/main/webapp/frontend/package.json +++ b/sermant-backend/src/main/webapp/frontend/package.json @@ -16,6 +16,7 @@ "moment": "^2.29.4", "qs": "^6.11.1", "vue": "^3.2.36", + "vue-i18n": "^9.13.1", "vue-router": "^4.1.6" }, "devDependencies": { diff --git a/sermant-backend/src/main/webapp/frontend/src/App.vue b/sermant-backend/src/main/webapp/frontend/src/App.vue index ef4205ab64..090d868a9e 100644 --- a/sermant-backend/src/main/webapp/frontend/src/App.vue +++ b/sermant-backend/src/main/webapp/frontend/src/App.vue @@ -1,8 +1,8 @@ @@ -17,3 +17,7 @@ margin: 1vh; } + + \ No newline at end of file diff --git a/sermant-backend/src/main/webapp/frontend/src/components/layouts/BaseHeader.vue b/sermant-backend/src/main/webapp/frontend/src/components/layouts/BaseHeader.vue index f13ae08449..374bf766b5 100644 --- a/sermant-backend/src/main/webapp/frontend/src/components/layouts/BaseHeader.vue +++ b/sermant-backend/src/main/webapp/frontend/src/components/layouts/BaseHeader.vue @@ -2,6 +2,7 @@ import {toggleDark} from "~/composables"; import {useRouter} from "vue-router"; import {ref} from "vue"; +import {switchLocale} from '~/composables/translations'; const activeName = ref("first"); @@ -35,24 +36,42 @@ const getAssetsImge = (url: string) => { - + - @@ -179,7 +188,7 @@ key - + key - + - + - +
- 提交 + {{ $t('configInfo.submit') }}
@@ -213,37 +222,61 @@ diff --git a/sermant-backend/src/main/webapp/frontend/src/views/EventsView.vue b/sermant-backend/src/main/webapp/frontend/src/views/EventsView.vue index e93ba6dee5..16a1b61d85 100644 --- a/sermant-backend/src/main/webapp/frontend/src/views/EventsView.vue +++ b/sermant-backend/src/main/webapp/frontend/src/views/EventsView.vue @@ -1,19 +1,19 @@