forked from akure/dao-dao-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
35 lines (31 loc) · 860 Bytes
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { initReactI18next } from 'react-i18next'
import i18n from 'i18next'
import Backend from 'i18next-http-backend'
import LanguageDetector from 'i18next-browser-languagedetector'
import config from './next-i18next.config'
const resources = config.ns.reduce((acc, n) => {
config.i18n.locales.forEach((lng) => {
if (!acc[lng]) acc[lng] = {}
acc[lng] = {
...acc[lng],
[n]: require(`./locales/${lng}/${n}.json`),
}
})
return acc
}, {})
i18n
.use(initReactI18next)
.use(LanguageDetector)
.use(Backend)
.init({
//debug: true,
lng: config.i18n.defaultLocale,
fallbackLng: config.i18n.defaultLocale,
defaultNS: config.defaultNS,
ns: config.ns,
interpolation: { escapeValue: false },
react: { useSuspense: false },
supportedLngs: config.i18n.locales,
resources,
})
export default i18n