diff options
author | Minteck <nekostarfan@gmail.com> | 2021-08-05 17:29:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-05 17:29:18 +0200 |
commit | b865b8f6586ffd4554cdfe45c739030afc882acd (patch) | |
tree | 37bcdf6575d8764b7367f34544658886879c0c5e /lang/loader.js | |
parent | 79edea37d15f88f086f7775bbbce64a57535b043 (diff) | |
parent | 7b541bbf2a8d754d26511895801d90f02cdf99f7 (diff) | |
download | kartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.tar.gz kartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.tar.bz2 kartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.zip |
Merge pull request #4 from Minteck-Projects/devel
Branching 21.08
Diffstat (limited to 'lang/loader.js')
-rw-r--r-- | lang/loader.js | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/lang/loader.js b/lang/loader.js index fdd5ec2..b28e004 100644 --- a/lang/loader.js +++ b/lang/loader.js @@ -1,46 +1,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()); - } -} +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());
+ }
+}
|