i18n.js 1.2 KB

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