From deee0d637b83f087172a8f084b9b978f248a8929 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 19:09:53 +0000 Subject: [PATCH 1/4] build(deps): bump vue-i18n from 9.1.10 to 9.2.0 Bumps [vue-i18n](https://github.com/intlify/vue-i18n-next/tree/HEAD/packages/vue-i18n) from 9.1.10 to 9.2.0. - [Release notes](https://github.com/intlify/vue-i18n-next/releases) - [Changelog](https://github.com/intlify/vue-i18n-next/blob/master/CHANGELOG.md) - [Commits](https://github.com/intlify/vue-i18n-next/commits/v9.2.0/packages/vue-i18n) --- updated-dependencies: - dependency-name: vue-i18n dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 178 +++++++++++++++++----------------------------- package.json | 2 +- 2 files changed, 68 insertions(+), 112 deletions(-) diff --git a/package-lock.json b/package-lock.json index c7516228..b76ab87f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,7 @@ "ssh2-promise": "~1.0.2", "v-mask": "~2.3.0", "vue": "~3.2.37", - "vue-i18n": "~9.1.9", + "vue-i18n": "~9.2.0", "vuedraggable": "~4.1.0" }, "devDependencies": { @@ -2031,85 +2031,60 @@ } }, "node_modules/@intlify/core-base": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.1.10.tgz", - "integrity": "sha512-So9CNUavB/IsZ+zBmk2Cv6McQp6vc2wbGi1S0XQmJ8Vz+UFcNn9MFXAe9gY67PreIHrbLsLxDD0cwo1qsxM1Nw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.2.0.tgz", + "integrity": "sha512-PkaiY9FAzZHAwPNaS+3csXR6L5k8LFBsSjn63/dy5BqE3pOJd07R4+NYtk8ezxymUemu7p5cS9YX77cmnQO6aQ==", "dependencies": { - "@intlify/devtools-if": "9.1.10", - "@intlify/message-compiler": "9.1.10", - "@intlify/message-resolver": "9.1.10", - "@intlify/runtime": "9.1.10", - "@intlify/shared": "9.1.10", - "@intlify/vue-devtools": "9.1.10" + "@intlify/devtools-if": "9.2.0", + "@intlify/message-compiler": "9.2.0", + "@intlify/shared": "9.2.0", + "@intlify/vue-devtools": "9.2.0" }, "engines": { - "node": ">= 10" + "node": ">= 14" } }, "node_modules/@intlify/devtools-if": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.1.10.tgz", - "integrity": "sha512-SHaKoYu6sog3+Q8js1y3oXLywuogbH1sKuc7NSYkN3GElvXSBaMoCzW+we0ZSFqj/6c7vTNLg9nQ6rxhKqYwnQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.2.0.tgz", + "integrity": "sha512-8yfusyhUaqInnn6Cma+NTTh5+EWyrnAkez36qADetbUnY4tCeGyAy+MmIAGh0uqmJVIeX94vd6L1AaA0p9McGg==", "dependencies": { - "@intlify/shared": "9.1.10" + "@intlify/shared": "9.2.0" }, "engines": { - "node": ">= 10" + "node": ">= 14" } }, "node_modules/@intlify/message-compiler": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.1.10.tgz", - "integrity": "sha512-+JiJpXff/XTb0EadYwdxOyRTB0hXNd4n1HaJ/a4yuV960uRmPXaklJsedW0LNdcptd/hYUZtCkI7Lc9J5C1gxg==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.2.0.tgz", + "integrity": "sha512-KGwwZsl+Nw2O26ZOKdytncxzKnMZ236KmM70u4GePgbizI+pu8yAh0apKxljSPzEJ7WECKTVc9R+laG12EJQYA==", "dependencies": { - "@intlify/message-resolver": "9.1.10", - "@intlify/shared": "9.1.10", + "@intlify/shared": "9.2.0", "source-map": "0.6.1" }, "engines": { - "node": ">= 10" - } - }, - "node_modules/@intlify/message-resolver": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.1.10.tgz", - "integrity": "sha512-5YixMG/M05m0cn9+gOzd4EZQTFRUu8RGhzxJbR1DWN21x/Z3bJ8QpDYj6hC4FwBj5uKsRfKpJQ3Xqg98KWoA+w==", - "engines": { - "node": ">= 10" - } - }, - "node_modules/@intlify/runtime": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.1.10.tgz", - "integrity": "sha512-7QsuByNzpe3Gfmhwq6hzgXcMPpxz8Zxb/XFI6s9lQdPLPe5Lgw4U1ovRPZTOs6Y2hwitR3j/HD8BJNGWpJnOFA==", - "dependencies": { - "@intlify/message-compiler": "9.1.10", - "@intlify/message-resolver": "9.1.10", - "@intlify/shared": "9.1.10" - }, - "engines": { - "node": ">= 10" + "node": ">= 14" } }, "node_modules/@intlify/shared": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.1.10.tgz", - "integrity": "sha512-Om54xJeo1Vw+K1+wHYyXngE8cAbrxZHpWjYzMR9wCkqbhGtRV5VLhVc214Ze2YatPrWlS2WSMOWXR8JktX/IgA==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.2.0.tgz", + "integrity": "sha512-71uObL3Sy2ZiBQBMVETbkspE4Plpy87Hvlj6FAUF3xdD+M82tuxe3MVJjaD3ucqhtHmQWBkAWEurVLdPYr8G2g==", "engines": { - "node": ">= 10" + "node": ">= 14" } }, "node_modules/@intlify/vue-devtools": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.1.10.tgz", - "integrity": "sha512-5l3qYARVbkWAkagLu1XbDUWRJSL8br1Dj60wgMaKB0+HswVsrR6LloYZTg7ozyvM621V6+zsmwzbQxbVQyrytQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.2.0.tgz", + "integrity": "sha512-6P/tE/JdNNVo1z/sr/FnSd90OVlox2XuKMmzHR13nvpHGX7fjRn6pVv47L2jySOYG1cMezmYvJl14TAddKpw5Q==", "dependencies": { - "@intlify/message-resolver": "9.1.10", - "@intlify/runtime": "9.1.10", - "@intlify/shared": "9.1.10" + "@intlify/core-base": "9.2.0", + "@intlify/shared": "9.2.0" }, "engines": { - "node": ">= 10" + "node": ">= 14" } }, "node_modules/@jest/types": { @@ -16755,17 +16730,17 @@ } }, "node_modules/vue-i18n": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.1.10.tgz", - "integrity": "sha512-jpr7gV5KPk4n+sSPdpZT8Qx3XzTcNDWffRlHV/cT2NUyEf+sEgTTmLvnBAibjOFJ0zsUyZlVTAWH5DDnYep+1g==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.2.0.tgz", + "integrity": "sha512-vN8aW8Vn4r4eRhUgTLK1/kCIYMb3LQmuloa1YP4NsehiASCX0XCq50tgUAz1o0eBAZ8YvhdlaVPqlO7O0wCnkQ==", "dependencies": { - "@intlify/core-base": "9.1.10", - "@intlify/shared": "9.1.10", - "@intlify/vue-devtools": "9.1.10", - "@vue/devtools-api": "^6.0.0-beta.7" + "@intlify/core-base": "9.2.0", + "@intlify/shared": "9.2.0", + "@intlify/vue-devtools": "9.2.0", + "@vue/devtools-api": "^6.2.1" }, "engines": { - "node": ">= 10" + "node": ">= 14" }, "peerDependencies": { "vue": "^3.0.0" @@ -18966,64 +18941,45 @@ "dev": true }, "@intlify/core-base": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.1.10.tgz", - "integrity": "sha512-So9CNUavB/IsZ+zBmk2Cv6McQp6vc2wbGi1S0XQmJ8Vz+UFcNn9MFXAe9gY67PreIHrbLsLxDD0cwo1qsxM1Nw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.2.0.tgz", + "integrity": "sha512-PkaiY9FAzZHAwPNaS+3csXR6L5k8LFBsSjn63/dy5BqE3pOJd07R4+NYtk8ezxymUemu7p5cS9YX77cmnQO6aQ==", "requires": { - "@intlify/devtools-if": "9.1.10", - "@intlify/message-compiler": "9.1.10", - "@intlify/message-resolver": "9.1.10", - "@intlify/runtime": "9.1.10", - "@intlify/shared": "9.1.10", - "@intlify/vue-devtools": "9.1.10" + "@intlify/devtools-if": "9.2.0", + "@intlify/message-compiler": "9.2.0", + "@intlify/shared": "9.2.0", + "@intlify/vue-devtools": "9.2.0" } }, "@intlify/devtools-if": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.1.10.tgz", - "integrity": "sha512-SHaKoYu6sog3+Q8js1y3oXLywuogbH1sKuc7NSYkN3GElvXSBaMoCzW+we0ZSFqj/6c7vTNLg9nQ6rxhKqYwnQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.2.0.tgz", + "integrity": "sha512-8yfusyhUaqInnn6Cma+NTTh5+EWyrnAkez36qADetbUnY4tCeGyAy+MmIAGh0uqmJVIeX94vd6L1AaA0p9McGg==", "requires": { - "@intlify/shared": "9.1.10" + "@intlify/shared": "9.2.0" } }, "@intlify/message-compiler": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.1.10.tgz", - "integrity": "sha512-+JiJpXff/XTb0EadYwdxOyRTB0hXNd4n1HaJ/a4yuV960uRmPXaklJsedW0LNdcptd/hYUZtCkI7Lc9J5C1gxg==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.2.0.tgz", + "integrity": "sha512-KGwwZsl+Nw2O26ZOKdytncxzKnMZ236KmM70u4GePgbizI+pu8yAh0apKxljSPzEJ7WECKTVc9R+laG12EJQYA==", "requires": { - "@intlify/message-resolver": "9.1.10", - "@intlify/shared": "9.1.10", + "@intlify/shared": "9.2.0", "source-map": "0.6.1" } }, - "@intlify/message-resolver": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.1.10.tgz", - "integrity": "sha512-5YixMG/M05m0cn9+gOzd4EZQTFRUu8RGhzxJbR1DWN21x/Z3bJ8QpDYj6hC4FwBj5uKsRfKpJQ3Xqg98KWoA+w==" - }, - "@intlify/runtime": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.1.10.tgz", - "integrity": "sha512-7QsuByNzpe3Gfmhwq6hzgXcMPpxz8Zxb/XFI6s9lQdPLPe5Lgw4U1ovRPZTOs6Y2hwitR3j/HD8BJNGWpJnOFA==", - "requires": { - "@intlify/message-compiler": "9.1.10", - "@intlify/message-resolver": "9.1.10", - "@intlify/shared": "9.1.10" - } - }, "@intlify/shared": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.1.10.tgz", - "integrity": "sha512-Om54xJeo1Vw+K1+wHYyXngE8cAbrxZHpWjYzMR9wCkqbhGtRV5VLhVc214Ze2YatPrWlS2WSMOWXR8JktX/IgA==" + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.2.0.tgz", + "integrity": "sha512-71uObL3Sy2ZiBQBMVETbkspE4Plpy87Hvlj6FAUF3xdD+M82tuxe3MVJjaD3ucqhtHmQWBkAWEurVLdPYr8G2g==" }, "@intlify/vue-devtools": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.1.10.tgz", - "integrity": "sha512-5l3qYARVbkWAkagLu1XbDUWRJSL8br1Dj60wgMaKB0+HswVsrR6LloYZTg7ozyvM621V6+zsmwzbQxbVQyrytQ==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.2.0.tgz", + "integrity": "sha512-6P/tE/JdNNVo1z/sr/FnSd90OVlox2XuKMmzHR13nvpHGX7fjRn6pVv47L2jySOYG1cMezmYvJl14TAddKpw5Q==", "requires": { - "@intlify/message-resolver": "9.1.10", - "@intlify/runtime": "9.1.10", - "@intlify/shared": "9.1.10" + "@intlify/core-base": "9.2.0", + "@intlify/shared": "9.2.0" } }, "@jest/types": { @@ -30087,14 +30043,14 @@ } }, "vue-i18n": { - "version": "9.1.10", - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.1.10.tgz", - "integrity": "sha512-jpr7gV5KPk4n+sSPdpZT8Qx3XzTcNDWffRlHV/cT2NUyEf+sEgTTmLvnBAibjOFJ0zsUyZlVTAWH5DDnYep+1g==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.2.0.tgz", + "integrity": "sha512-vN8aW8Vn4r4eRhUgTLK1/kCIYMb3LQmuloa1YP4NsehiASCX0XCq50tgUAz1o0eBAZ8YvhdlaVPqlO7O0wCnkQ==", "requires": { - "@intlify/core-base": "9.1.10", - "@intlify/shared": "9.1.10", - "@intlify/vue-devtools": "9.1.10", - "@vue/devtools-api": "^6.0.0-beta.7" + "@intlify/core-base": "9.2.0", + "@intlify/shared": "9.2.0", + "@intlify/vue-devtools": "9.2.0", + "@vue/devtools-api": "^6.2.1" } }, "vue-loader": { diff --git a/package.json b/package.json index 8e467b2a..1c67a7d6 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "ssh2-promise": "~1.0.2", "v-mask": "~2.3.0", "vue": "~3.2.37", - "vue-i18n": "~9.1.9", + "vue-i18n": "~9.2.0", "vuedraggable": "~4.1.0" }, "devDependencies": { From 104b7c928b9c2abfc056880f16c606a0b1fa7c67 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Fri, 5 Aug 2022 12:25:14 +0200 Subject: [PATCH 2/4] fix: set legacy: false --- src/renderer/i18n/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderer/i18n/index.ts b/src/renderer/i18n/index.ts index ef195f25..0260d6e4 100644 --- a/src/renderer/i18n/index.ts +++ b/src/renderer/i18n/index.ts @@ -2,6 +2,7 @@ import { createI18n } from 'vue-i18n'; const i18n = createI18n({ fallbackLocale: 'en-US', + legacy: false, messages: { 'en-US': require('./en-US'), 'it-IT': require('./it-IT'), From f4da28cca06cbd712c88f92c031d40fabdedc760 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Fri, 5 Aug 2022 12:57:56 +0200 Subject: [PATCH 3/4] refactor: vue-i18n ts improvements --- src/renderer/i18n/ar-SA.ts | 2 +- src/renderer/i18n/de-DE.ts | 2 +- src/renderer/i18n/en-US.ts | 2 +- src/renderer/i18n/es-ES.ts | 2 +- src/renderer/i18n/fr-FR.ts | 2 +- src/renderer/i18n/index.ts | 48 +++++++++++++++++++++++++++----------- src/renderer/i18n/it-IT.ts | 2 +- src/renderer/i18n/ja-JP.ts | 2 +- src/renderer/i18n/pt-BR.ts | 2 +- src/renderer/i18n/ru-RU.ts | 2 +- src/renderer/i18n/vi-VN.ts | 2 +- src/renderer/i18n/zh-CN.ts | 2 +- 12 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/renderer/i18n/ar-SA.ts b/src/renderer/i18n/ar-SA.ts index 867159d4..ad9cec2a 100644 --- a/src/renderer/i18n/ar-SA.ts +++ b/src/renderer/i18n/ar-SA.ts @@ -1,4 +1,4 @@ -module.exports = { +export const arSA = { word: { edit: 'تعديل', save: 'حفظ', diff --git a/src/renderer/i18n/de-DE.ts b/src/renderer/i18n/de-DE.ts index 3e814ad2..fde6ef85 100644 --- a/src/renderer/i18n/de-DE.ts +++ b/src/renderer/i18n/de-DE.ts @@ -1,4 +1,4 @@ -module.exports = { +export const deDE = { word: { edit: 'Bearbeiten', save: 'Speichern', diff --git a/src/renderer/i18n/en-US.ts b/src/renderer/i18n/en-US.ts index beb6f83e..51a1d5f1 100644 --- a/src/renderer/i18n/en-US.ts +++ b/src/renderer/i18n/en-US.ts @@ -1,4 +1,4 @@ -module.exports = { +export const enUS = { word: { edit: 'Edit', save: 'Save', diff --git a/src/renderer/i18n/es-ES.ts b/src/renderer/i18n/es-ES.ts index 9cb42a89..998475c7 100644 --- a/src/renderer/i18n/es-ES.ts +++ b/src/renderer/i18n/es-ES.ts @@ -1,4 +1,4 @@ -module.exports = { +export const esES = { word: { edit: 'Editar', save: 'Guardar', diff --git a/src/renderer/i18n/fr-FR.ts b/src/renderer/i18n/fr-FR.ts index 9df6efd3..5101b554 100644 --- a/src/renderer/i18n/fr-FR.ts +++ b/src/renderer/i18n/fr-FR.ts @@ -1,4 +1,4 @@ -module.exports = { +export const frFR = { word: { edit: 'Editer', save: 'Sauver', diff --git a/src/renderer/i18n/index.ts b/src/renderer/i18n/index.ts index 0260d6e4..e84e87dc 100644 --- a/src/renderer/i18n/index.ts +++ b/src/renderer/i18n/index.ts @@ -1,20 +1,40 @@ import { createI18n } from 'vue-i18n'; +import { enUS } from './en-US'; +import { itIT } from './it-IT'; +import { arSA } from './ar-SA'; +import { esES } from './es-ES'; +import { frFR } from './fr-FR'; +import { ptBR } from './pt-BR'; +import { deDE } from './de-DE'; +import { viVN } from './vi-VN'; +import { jaJP } from './ja-JP'; +import { zhCN } from './zh-CN'; +import { ruRU } from './ru-RU'; -const i18n = createI18n({ +const messages = { + 'en-US': enUS, + 'it-IT': itIT, + 'ar-SA': arSA, + 'es-ES': esES, + 'fr-FR': frFR, + 'pt-BR': ptBR, + 'de-DE': deDE, + 'vi-VN': viVN, + 'ja-JP': jaJP, + 'zh-CN': zhCN, + 'ru-RU': ruRU +}; + +type NestedPartial = { + [K in keyof T]?: T[K] extends Array ? Array> : (T[K] extends unknown ? unknown : NestedPartial) +}; + +type MessageSchema = typeof enUS +type AvailableLocales = keyof typeof messages + +const i18n = createI18n<[NestedPartial], AvailableLocales>({ fallbackLocale: 'en-US', legacy: false, - messages: { - 'en-US': require('./en-US'), - 'it-IT': require('./it-IT'), - 'ar-SA': require('./ar-SA'), - 'es-ES': require('./es-ES'), - 'fr-FR': require('./fr-FR'), - 'pt-BR': require('./pt-BR'), - 'de-DE': require('./de-DE'), - 'vi-VN': require('./vi-VN'), - 'ja-JP': require('./ja-JP'), - 'zh-CN': require('./zh-CN'), - 'ru-RU': require('./ru-RU') - } + messages }); export default i18n; diff --git a/src/renderer/i18n/it-IT.ts b/src/renderer/i18n/it-IT.ts index 4ab3b4ed..7ef7e025 100644 --- a/src/renderer/i18n/it-IT.ts +++ b/src/renderer/i18n/it-IT.ts @@ -1,4 +1,4 @@ -module.exports = { +export const itIT = { word: { edit: 'Modifica', save: 'Salva', diff --git a/src/renderer/i18n/ja-JP.ts b/src/renderer/i18n/ja-JP.ts index ad260399..45f13254 100644 --- a/src/renderer/i18n/ja-JP.ts +++ b/src/renderer/i18n/ja-JP.ts @@ -1,4 +1,4 @@ -module.exports = { +export const jaJP = { word: { edit: '編集', save: '保存', diff --git a/src/renderer/i18n/pt-BR.ts b/src/renderer/i18n/pt-BR.ts index caf0221f..2e438459 100644 --- a/src/renderer/i18n/pt-BR.ts +++ b/src/renderer/i18n/pt-BR.ts @@ -1,4 +1,4 @@ -module.exports = { +export const ptBR = { word: { edit: 'Editar', save: 'Salvar', diff --git a/src/renderer/i18n/ru-RU.ts b/src/renderer/i18n/ru-RU.ts index ccfb2283..f0ef0024 100644 --- a/src/renderer/i18n/ru-RU.ts +++ b/src/renderer/i18n/ru-RU.ts @@ -1,4 +1,4 @@ -module.exports = { +export const ruRU = { word: { edit: 'Редактировать', save: 'Сохранить', diff --git a/src/renderer/i18n/vi-VN.ts b/src/renderer/i18n/vi-VN.ts index 89df64a3..8dba0441 100644 --- a/src/renderer/i18n/vi-VN.ts +++ b/src/renderer/i18n/vi-VN.ts @@ -1,4 +1,4 @@ -module.exports = { +export const viVN = { word: { edit: 'Chỉnh sửa', save: 'Lưu', diff --git a/src/renderer/i18n/zh-CN.ts b/src/renderer/i18n/zh-CN.ts index 1cc12d37..deeefafa 100644 --- a/src/renderer/i18n/zh-CN.ts +++ b/src/renderer/i18n/zh-CN.ts @@ -1,4 +1,4 @@ -module.exports = { +export const zhCN = { word: { edit: '编辑', save: '保存', From 09a372e96dbff40e2db6ae31b6844685da546b05 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Fri, 5 Aug 2022 13:06:08 +0200 Subject: [PATCH 4/4] refactor: vue-i18n ts improvements --- src/renderer/components/ModalSettings.vue | 4 ++-- src/renderer/i18n/index.ts | 6 +++--- src/renderer/stores/settings.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/renderer/components/ModalSettings.vue b/src/renderer/components/ModalSettings.vue index 62fd7c0e..99cfd0f2 100644 --- a/src/renderer/components/ModalSettings.vue +++ b/src/renderer/components/ModalSettings.vue @@ -329,7 +329,7 @@ import ModalSettingsChangelog from '@/components/ModalSettingsChangelog.vue'; import BaseTextEditor from '@/components/BaseTextEditor.vue'; import BaseSelect from '@/components/BaseSelect.vue'; -const { t, availableLocales } = useI18n(); +const { t, AvailableLocale } = useI18n(); const applicationStore = useApplicationStore(); const settingsStore = useSettingsStore(); @@ -456,7 +456,7 @@ const selectedTab: Ref = ref('general'); const locales = computed(() => { const locales = []; - for (const locale of availableLocales) + for (const locale of AvailableLocale) locales.push({ code: locale, name: localesNames[locale] }); return locales; diff --git a/src/renderer/i18n/index.ts b/src/renderer/i18n/index.ts index e84e87dc..72d42d03 100644 --- a/src/renderer/i18n/index.ts +++ b/src/renderer/i18n/index.ts @@ -29,10 +29,10 @@ type NestedPartial = { [K in keyof T]?: T[K] extends Array ? Array> : (T[K] extends unknown ? unknown : NestedPartial) }; -type MessageSchema = typeof enUS -type AvailableLocales = keyof typeof messages +export type MessageSchema = typeof enUS +export type AvailableLocale = keyof typeof messages -const i18n = createI18n<[NestedPartial], AvailableLocales>({ +const i18n = createI18n<[NestedPartial], AvailableLocale>({ fallbackLocale: 'en-US', legacy: false, messages diff --git a/src/renderer/stores/settings.ts b/src/renderer/stores/settings.ts index 6b1b87c4..af8f58ea 100644 --- a/src/renderer/stores/settings.ts +++ b/src/renderer/stores/settings.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia'; import { ipcRenderer } from 'electron'; -import i18n from '@/i18n'; +import i18n, { AvailableLocale } from '@/i18n'; import * as Store from 'electron-store'; const persistentStore = new Store({ name: 'settings' }); const isDarkTheme = window.matchMedia('(prefers-color-scheme: dark)'); @@ -12,7 +12,7 @@ export type ApplicationTheme = 'light' | 'dark'; export const useSettingsStore = defineStore('settings', { state: () => ({ - locale: persistentStore.get('locale', 'en-US') as string, + locale: persistentStore.get('locale', 'en-US') as AvailableLocale, allowPrerelease: persistentStore.get('allow_prerelease', true) as boolean, explorebarSize: persistentStore.get('explorebar_size', null) as number, notificationsTimeout: persistentStore.get('notifications_timeout', 5) as number, @@ -27,7 +27,7 @@ export const useSettingsStore = defineStore('settings', { disableScratchpad: persistentStore.get('disable_scratchpad', false) as boolean }), actions: { - changeLocale (locale: string) { + changeLocale (locale: AvailableLocale) { this.locale = locale; i18n.global.locale = locale; persistentStore.set('locale', this.locale);