Compare commits

..

No commits in common. "b7c97ead2b6ffaf2724d2b8e98d0d810478e343d" and "8fdfb470cb3c130f0d0e3bde1adc9b7e4edb1981" have entirely different histories.

View File

@ -10,10 +10,9 @@
*/
import { getCookie, setCookie } from './utils.js';
import { reactive } from 'vue';
const default_lang = "EN";
const langs = reactive({});
let langs;
/**
@ -28,8 +27,8 @@ const langs = reactive({});
export default function i18n(key, options) {
let ret = langs[key];
if(options != null){
for (let option in options) {
ret = ret.replaceAll("$" + option, options[option]);
for (let key in options) {
ret = ret.replaceAll("$" + key, options[key]);
}
}
return ret;
@ -48,12 +47,14 @@ export async function loadLangs(lang){
const content = await (await fetch(filename)).text();
const lines = content.split("\n");
let filteredLines = {};
for (let line of lines) {
if(!line.trim().startsWith("#") && line.trim() != ""){
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();