bugfix and random linter bs

This commit is contained in:
Erik 2020-05-24 12:00:54 +03:00
parent dae5918000
commit e22dbd15b0

View File

@ -35,7 +35,7 @@ class LocaleLoader {
const directory = path.join(process.cwd(), `language/languages/${language}`);
const files = Util.readdirRecursive(directory);
let combined = {};
const combined = {};
for(let file of files) {
file = fs.readFileSync(file, {
encoding: 'utf8'
@ -57,27 +57,25 @@ class LocaleLoader {
let text = '';
for(const line of lines) {
if(line.startsWith('//')) continue;
const matches = line.match(/\[([_A-Z0-9]{1,})]/, 'gi');
const matches = line.match(/\[([_A-Z0-9]{1,})\]/giu);
if(matches) {
if(matched) {
if (matched) {
parsed[matched] = text;
matched = matches[1];
[, matched] = matches;
text = '';
} else {
matched = matches[1];
[, matched] = matches;
}
} else if(matched) {
text += line;
} else {
if(matched) {
text += line;
} else {
continue;
}
continue;
}
}
parsed[matched] = text;
for(const [ key, value ] of Object.entries(parsed)) {
parsed[key] = value.replace(/^(\r)|(\r){1,}$/g, '');
parsed[key] = value.replace(/^(\r)|(\r){1,}$/gu, '').replace(/\r/gu, '\n');
}
return parsed;