index.js 585 B

12345678910111213141516171819202122
  1. import i18n from 'i18next';
  2. import {initReactI18next} from 'react-i18next';
  3. // 导入本地语言包
  4. import en from './locales/en.json';
  5. import zh from './locales/zh.json';
  6. i18n
  7. .use(initReactI18next)
  8. .init({
  9. resources: {
  10. en: {translation: en},
  11. zh: {translation: zh},
  12. },
  13. lng: 'en', // 默认语言
  14. fallbackLng: 'en', // 找不到翻译时使用的语言
  15. interpolation: {
  16. escapeValue: false, // 防止 XSS(React 已经安全处理)
  17. },
  18. });
  19. export default i18n;