Compare commits
No commits in common. "b7c97ead2b6ffaf2724d2b8e98d0d810478e343d" and "8fdfb470cb3c130f0d0e3bde1adc9b7e4edb1981" have entirely different histories.
b7c97ead2b
...
8fdfb470cb
@ -10,10 +10,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { getCookie, setCookie } from './utils.js';
|
import { getCookie, setCookie } from './utils.js';
|
||||||
import { reactive } from 'vue';
|
|
||||||
|
|
||||||
const default_lang = "EN";
|
const default_lang = "EN";
|
||||||
const langs = reactive({});
|
let langs;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,8 +27,8 @@ const langs = reactive({});
|
|||||||
export default function i18n(key, options) {
|
export default function i18n(key, options) {
|
||||||
let ret = langs[key];
|
let ret = langs[key];
|
||||||
if(options != null){
|
if(options != null){
|
||||||
for (let option in options) {
|
for (let key in options) {
|
||||||
ret = ret.replaceAll("$" + option, options[option]);
|
ret = ret.replaceAll("$" + key, options[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -48,12 +47,14 @@ export async function loadLangs(lang){
|
|||||||
const content = await (await fetch(filename)).text();
|
const content = await (await fetch(filename)).text();
|
||||||
const lines = content.split("\n");
|
const lines = content.split("\n");
|
||||||
|
|
||||||
|
let filteredLines = {};
|
||||||
for (let line of lines) {
|
for (let line of lines) {
|
||||||
if(!line.trim().startsWith("#") && line.trim() != ""){
|
if(!line.trim().startsWith("#") && line.trim() != ""){
|
||||||
let split = line.indexOf("=")
|
let split = line.indexOf("=")
|
||||||
langs[line.substr(0, split)] = line.substr(split+1, line.length);
|
filteredLines[line.substr(0, split)] = line.substr(split+1, line.length);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
langs = filteredLines;
|
||||||
}
|
}
|
||||||
await loadLangs();
|
await loadLangs();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user