-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathi18n.js
51 lines (36 loc) · 1.03 KB
/
i18n.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
const Resources = require('./locales/index.js');
const i18n = require('i18next');
const LanguageDetector = require('i18next-browser-languagedetector');
const reactI18nextModule = require('react-i18next');
const languageList = require('./lists/languages').languages;
const options = {
lng: 'en',
fallbackLng: 'en',
load: 'all', // no region specific locals like en-US, de-DE
ns: ['common', 'home'], // have a common namespace used around the full app
defaultNS: 'common',
preload: languageList,
initImmediate: false,
appendNamespaceToMissingKey: true,
resources: Resources,
debug: false,
saveMissing: false,
updateMissing: false,
interpolation: {
escapeValue: true,
formatSeparator: ',',
format: (value, format) => {
if (format === 'uppercase') return value.toUpperCase();
return value;
},
},
react: {
wait: false,
},
};
if (process.browser) {
i18n.use(LanguageDetector);
}
i18n.use(reactI18nextModule);
if (!i18n.isInitialized) i18n.init(options);
module.exports = i18n;