tooot/src/i18n/i18n.ts

30 lines
690 B
TypeScript
Raw Normal View History

2021-01-17 22:37:05 +01:00
import { store } from '@root/store'
import { getSettingsLanguage, supportedLngs } from '@utils/slices/settingsSlice'
import i18next from 'i18next'
import { initReactI18next } from 'react-i18next'
2020-12-13 14:04:25 +01:00
import en from '@root/i18n/en/_all'
2021-01-17 22:37:05 +01:00
import zh_Hans from '@root/i18n/zh-Hans/_all'
2020-11-29 18:08:31 +01:00
i18next.use(initReactI18next).init({
2021-01-17 22:37:05 +01:00
lng: getSettingsLanguage(store.getState()),
fallbackLng: 'en',
supportedLngs: supportedLngs,
ns: ['common'],
defaultNS: 'common',
2021-01-17 22:37:05 +01:00
resources: { 'zh-Hans': zh_Hans, en },
saveMissing: true,
2021-01-20 00:39:39 +01:00
missingKeyHandler: (ns, key) => {
console.log('i18n missing: ' + ns + ' : ' + key)
},
interpolation: {
escapeValue: false
2021-01-07 19:13:09 +01:00
}
})
export default i18next