i18n.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import i18n from 'i18next';
  2. import { initReactI18next } from 'react-i18next';
  3. import LanguageDetector from 'i18next-browser-languagedetector';
  4. import Backend from 'i18next-http-backend';
  5. import metaEN from './public/static/locales/en/meta.json';
  6. import metaTW from './public/static/locales/zh-tw/meta.json';
  7. import sidebarEN from './public/static/locales/en/sidebar.json';
  8. import sidebarTW from './public/static/locales/zh-tw/sidebar.json';
  9. import toolbarEN from './public/static/locales/en/toolbar.json';
  10. import toolbarTW from './public/static/locales/zh-tw/toolbar.json';
  11. import dialogEN from './public/static/locales/en/dialog.json';
  12. import dialogTW from './public/static/locales/zh-tw/dialog.json';
  13. import toastEN from './public/static/locales/en/toast.json';
  14. import toastTW from './public/static/locales/zh-tw/toast.json';
  15. const resources = {
  16. en: {
  17. meta: metaEN,
  18. sidebar: sidebarEN,
  19. toolbar: toolbarEN,
  20. dialog: dialogEN,
  21. toast: toastEN,
  22. },
  23. 'zh-TW': {
  24. meta: metaTW,
  25. sidebar: sidebarTW,
  26. toolbar: toolbarTW,
  27. dialog: dialogTW,
  28. toast: toastTW,
  29. },
  30. };
  31. i18n
  32. .use(Backend)
  33. .use(LanguageDetector)
  34. .use(initReactI18next) // passes i18n down to react-i18next
  35. .init({
  36. resources,
  37. lng: 'en',
  38. fallbackLng: 'en',
  39. interpolation: {
  40. escapeValue: false,
  41. },
  42. react: {
  43. useSuspense: false,
  44. },
  45. });
  46. export default i18n;