blob: b28e004bd3fe306c47903e3e907f62c10ab07481 (
plain)
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
|
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
if (getCookie("kartik_lang").trim() === "") {
document.cookie = "kartik_lang=en; path=/";
}
if (typeof native === "boolean" && !native) {
try {
global.lp = getCookie("kartik_lang");
global.ll_length = getCookie("kartik_i18n_" + lp) - 1 + 2;
global.ll_raw = "";
for (i = 1; i <= ll_length; i++) {
global.ll_raw = ll_raw + getCookie("kartik_i18n_" + lp + "_" + (i - 1));
}
global.lang = JSON.parse(ll_raw);
} catch (e) {
console.error(e);
global.lp = "en";
global.lang = JSON.parse(window.fetch("./lang/" + lp + ".json").toString());
}
} else {
try {
global.lp = require('electron').remote.getCurrentWindow().lp.trim();
global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
} catch (e) {
console.error(e);
global.lp = "en";
global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
}
}
|