i18n.ts 1007 B

1234567891011121314151617181920212223242526272829303132
  1. import i18n from 'i18next';
  2. import { initReactI18next } from 'react-i18next';
  3. import LanguageDetector from 'i18next-browser-languagedetector';
  4. import en from './locales/en.json';
  5. import zh from './locales/zh.json';
  6. import ja from './locales/ja.json';
  7. i18n
  8. .use(LanguageDetector)
  9. .use(initReactI18next)
  10. .init({
  11. resources: {
  12. en: { translation: en },
  13. zh: { translation: zh },
  14. ja: { translation: ja }
  15. },
  16. supportedLngs: ['zh', 'en', 'ja'],
  17. load: 'languageOnly', // matches 'en-US' -> 'en', 'zh-CN' -> 'zh'
  18. fallbackLng: 'zh',
  19. detection: {
  20. // order: ['querystring', 'cookie', 'localStorage', 'navigator', 'htmlTag', 'path', 'subdomain'],
  21. order: ['localStorage', 'navigator'],
  22. caches: ['localStorage'],
  23. },
  24. debug: false,
  25. interpolation: {
  26. escapeValue: false // not needed for react as it escapes by default
  27. }
  28. });
  29. export default i18n;