i18n.js 780 B

12345678910111213141516171819202122232425262728293031323334
  1. import i18n from 'i18next';
  2. import * as Localization from 'expo-localization';
  3. import { initReactI18next } from 'react-i18next';
  4. import en from './locales/en.json';
  5. import zh from './locales/zh-CN.json';
  6. import th from './locales/th.json';
  7. const resources = {
  8. zh: {
  9. translation: zh,
  10. },
  11. en: {
  12. translation: en,
  13. },
  14. th: {
  15. translation: th,
  16. },
  17. };
  18. i18n
  19. .use(initReactI18next) // passes i18n down to react-i18next
  20. .init({
  21. resources,
  22. lng: Localization.locale,
  23. fallbackLng: 'zh-CN', // use en if detected lng is not available
  24. keySeparator: false, // we do not use keys in form messages.welcome
  25. interpolation: {
  26. escapeValue: false, // react already safes from xss
  27. },
  28. });
  29. export default i18n;