From 1e2d8fa0277fa1b9b129c9f2156389efe78c7c44 Mon Sep 17 00:00:00 2001 From: elvis liao <1219585136@qq.com> Date: Fri, 27 Sep 2024 16:31:24 +0800 Subject: [PATCH] chore: abstract resources configure --- ui/src/i18n/index.ts | 15 ++------------- ui/src/i18n/locales/index.ts | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 ui/src/i18n/locales/index.ts diff --git a/ui/src/i18n/index.ts b/ui/src/i18n/index.ts index eaed9c9a..60718b00 100644 --- a/ui/src/i18n/index.ts +++ b/ui/src/i18n/index.ts @@ -2,24 +2,13 @@ import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import LanguageDetector from 'i18next-browser-languagedetector'; -import zh from './locales/zh.json' -import en from './locales/en.json' - +import resources from './locales' i18n .use(LanguageDetector) .use(initReactI18next) .init({ - resources: { - zh: { - name: '简体中文', - translation: zh - }, - en: { - name: 'English', - translation: en - } - }, + resources, fallbackLng: 'zh', debug: true, interpolation: { diff --git a/ui/src/i18n/locales/index.ts b/ui/src/i18n/locales/index.ts new file mode 100644 index 00000000..aff60842 --- /dev/null +++ b/ui/src/i18n/locales/index.ts @@ -0,0 +1,17 @@ +import { Resource } from 'i18next' + +import zh from './zh.json' +import en from './en.json' + +const resources: Resource = { + zh: { + name: '简体中文', + translation: zh + }, + en: { + name: 'English', + translation: en + } +} + +export default resources; \ No newline at end of file