i18n.ts 560 B

1234567891011121314151617181920212223242526272829303132
  1. import en from '@/locales/en';
  2. import zh from '@/locales/zh';
  3. import i18n from 'i18next';
  4. import { initReactI18next } from 'react-i18next';
  5. export type I18nKeys = keyof typeof en;
  6. interface Resources {
  7. translation: Record<I18nKeys, string>;
  8. }
  9. i18n.use(initReactI18next).init({
  10. resources: {
  11. en: {
  12. translation: en,
  13. },
  14. zh: {
  15. translation: zh,
  16. },
  17. },
  18. lng: 'en',
  19. interpolation: {
  20. escapeValue: false,
  21. },
  22. });
  23. export default i18n;
  24. declare module 'i18next' {
  25. interface CustomTypeOptions {
  26. resources: Resources;
  27. }
  28. }