-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi18n.js
52 lines (46 loc) · 1.36 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
52
import i18n from "i18next";
import Backend from "i18next-xhr-backend";
import LanguageDetector from "i18next-browser-languagedetector";
import { reactI18nextModule } from "react-i18next";
import moment from "moment";
import numeral from "numeral";
//can set no cache from server but this time for easy
// import {v4} from 'uuid';
// import { VERSION } from "./store/constants/api";
i18n
.use(Backend)
.use(LanguageDetector)
.use(reactI18nextModule)
.init({
// init after translated file loaded completely
initImmediate: false,
whitelist: ["en", "es", "fr", "ja", "ko", "th", "vi", "zh"],
fallbackLng: [],
load: "languageOnly", // auto remove suffix
// have a common namespace used around the full app
ns: ["translations"],
defaultNS: "translations",
// backend: {
// queryStringParams: {
// v: v4(),
// }
// },
debug: true,
interpolation: {
escapeValue: false, // not needed for react!!
format(value, format, lng) {
switch (format) {
case "uppercase":
return value.toUpperCase();
default:
if (typeof value === "number") return numeral(value).format(format);
if (value instanceof Date) return moment(value).format(format);
return value;
}
}
},
react: {
wait: true
}
});
export default i18n;