From bdd29116658c8481a5d704bd65f2d58d7a37598f Mon Sep 17 00:00:00 2001 From: LeoKu Date: Wed, 4 May 2022 11:34:34 +0800 Subject: [PATCH] chore: add locale --- .eslintrc.js | 1 + src/__tests__/utils.test.ts | 18 ++++++++++++++++-- src/components/Configurator.vue | 2 +- src/components/SectionWrapper.vue | 1 + src/components/VueColorAvatar.vue | 2 +- src/i18n/locales/en/index.ts | 1 + src/i18n/locales/zh/index.ts | 1 + 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2908927..ee04dc6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -44,6 +44,7 @@ module.exports = { '@typescript-eslint/explicit-module-boundary-types': 0, '@typescript-eslint/consistent-type-imports': 1, '@typescript-eslint/no-non-null-assertion': 0, + '@typescript-eslint/no-explicit-any': 0, }, ignorePatterns: [ 'dist', diff --git a/src/__tests__/utils.test.ts b/src/__tests__/utils.test.ts index 2f4f169..eb3d21c 100644 --- a/src/__tests__/utils.test.ts +++ b/src/__tests__/utils.test.ts @@ -9,8 +9,22 @@ test('highlightJSON', () => { expect(highlightJSON(str)).toMatch('string') }) +const getKeys = (target: Record) => { + const keys: string[] = [] + + for (const key in target) { + if (typeof target[key] === 'object') { + keys.push(...getKeys(target[key])) + } else { + keys.push(key) + } + } + + return keys +} + test('check locales completeness', () => { - const zh = Reflect.ownKeys(localeZH).sort() - const en = Reflect.ownKeys(localeEN).sort() + const zh = getKeys(localeZH).sort() + const en = getKeys(localeEN).sort() expect(zh).toEqual(en) }) diff --git a/src/components/Configurator.vue b/src/components/Configurator.vue index 5e69a76..6e6c9e9 100644 --- a/src/components/Configurator.vue +++ b/src/components/Configurator.vue @@ -67,7 +67,7 @@ " class="color-picker" > - 颜色 + {{ t('label.colors') }}