diff --git a/src/i18next.js b/src/i18n/i18n.js similarity index 70% rename from src/i18next.js rename to src/i18n/i18n.js index 0e916471..afa861ce 100644 --- a/src/i18next.js +++ b/src/i18n/i18n.js @@ -2,6 +2,10 @@ import i18n from 'i18next' // import Backend from 'i18next-http-backend' import { initReactI18next } from 'react-i18next' import LanguageDetector from 'i18next-browser-languagedetector' +import translationInZh from '../locales/zh/translation.json' +import translationInEn from '../locales/en/translation.json' +// import translationInZh from '../locales/zh/translation' +// import translationInEn from '../locales/en/translation' i18n // .use(Backend) @@ -13,18 +17,10 @@ i18n // }, resources: { en: { - translation: { - demo: 'Demo', - lang: 'En', - home: 'Home', - }, + translation: translationInEn, }, zh: { - translation: { - demo: '演示', - lang: 'ZH', - home: '首页', - }, + translation: translationInZh, }, }, lng: 'zh', diff --git a/src/index.tsx b/src/index.tsx index 72a04fb0..d459a519 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client' import { I18nextProvider } from 'react-i18next' import ThemeIndex from './theme' import { ProThemeProvider } from './theme/hooks' -import i18n from './i18next' +import i18n from './i18n/i18n' const root = ReactDOM.createRoot(document.getElementById('root') as HTMLDivElement) diff --git a/src/locales/en/translation.js b/src/locales/en/translation.js new file mode 100644 index 00000000..ed95d484 --- /dev/null +++ b/src/locales/en/translation.js @@ -0,0 +1,7 @@ +const en = { + demo: 'Demo', + lang: 'En', + home: 'Home', +} + +export default en diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json new file mode 100644 index 00000000..20c9c34a --- /dev/null +++ b/src/locales/en/translation.json @@ -0,0 +1,5 @@ +{ + "demo": "Demo", + "lang": "En", + "home": "Home" +} diff --git a/src/locales/zh/translation.js b/src/locales/zh/translation.js new file mode 100644 index 00000000..169bb049 --- /dev/null +++ b/src/locales/zh/translation.js @@ -0,0 +1,7 @@ +const zh = { + demo: '演示', + lang: 'ZH', + home: '首页', +} + +export default zh diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json new file mode 100644 index 00000000..1ecd5723 --- /dev/null +++ b/src/locales/zh/translation.json @@ -0,0 +1,5 @@ +{ + "demo": "演示", + "lang": "ZH", + "home": "首页" +} diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index bb9a0ac3..47f95be2 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -218,14 +218,6 @@ const config = { }, ], }, - { - test: /\.json$/, - type: 'asset/resource', // 将json文件视为文件类型 - generator: { - // 这里专门针对json文件的处理 - filename: 'static/json/[name].[hash][ext][query]', - }, - }, ], }, }