-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathi18n.init.js
53 lines (48 loc) · 1.08 KB
/
i18n.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import i18next from 'i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
import { languages, defaultLanguage } from './i18n.config'
const locales = Object.assign(
{},
...Object.keys(languages).map((index) => {
return {
[languages[index]]: {
translations: require('./public/locales/' + languages[index] + '/common.json'),
},
}
}),
)
const detection = {
order: [
'querystring',
'cookie',
'localStorage',
'sessionStorage',
'navigator',
'htmlTag',
'path',
'subdomain',
],
lookupCookie: 'lng',
lookupLocalStorage: 'lng',
lookupFromPathIndex: 0,
lookupFromSubdomainIndex: 0,
caches: ['localStorage', 'cookie'],
excludeCacheFor: ['cimode'],
cookieOptions: { path: '/', sameSite: 'strict' },
}
i18next.use(LanguageDetector).init({
detection: detection,
fallbackLng: defaultLanguage,
resources: locales,
ns: ['translations'],
defaultNS: 'translations',
returnObjects: true,
debug: false,
interpolation: {
escapeValue: false,
},
react: {
wait: true,
},
})
export default i18next