-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathi18n.js
42 lines (41 loc) · 1.11 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
/**
* ? Change the languages that are going to be built into UI
* ? the very first language here is also a fallback language
*/
const i18nlang = ["en", "es", "ru"];
// See: https://www.i18next.com/overview
import i18next from "i18next";
// See: https://github.com/i18next/jquery-i18next
const $i18next = require("jquery-i18next");
// See: https://github.com/i18next/i18next-browser-languageDetector
import LanguageDetector from "i18next-browser-languagedetector";
//
const i18nResources = () => {
let a = {};
for (let l in i18nlang) {
a[i18nlang[l]] = require("../lang/" + i18nlang[l] + ".json");
}
return a;
};
//
i18next.use(LanguageDetector).init({
debug: false,
fallbackLng: i18nlang[0],
useDataAttrOptions: true,
resources: i18nResources(),
detection: {
lookupQuerystring: "lng",
caches: ["localStorage", "cookie"],
order: [
"querystring",
"navigator",
"localStorage",
"sessionStorage",
"cookie",
"htmlTag",
],
},
});
$i18next.init(i18next, $, {
useOptionsAttr: true,
});