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 directory = path.join(process.cwd(), `language/languages/${language}`);
const files = Util.readdirRecursive(directory); const files = Util.readdirRecursive(directory);
let combined = {}; const combined = {};
for(let file of files) { for(let file of files) {
file = fs.readFileSync(file, { file = fs.readFileSync(file, {
encoding: 'utf8' encoding: 'utf8'
@ -57,27 +57,25 @@ class LocaleLoader {
let text = ''; let text = '';
for(const line of lines) { for(const line of lines) {
if(line.startsWith('//')) continue; 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(matches) {
if (matched) { if (matched) {
parsed[matched] = text; parsed[matched] = text;
matched = matches[1]; [, matched] = matches;
text = ''; text = '';
} else { } else {
matched = matches[1]; [, matched] = matches;
} }
} else { } else if(matched) {
if(matched) {
text += line; text += line;
} else { } else {
continue; continue;
} }
} }
}
parsed[matched] = text; parsed[matched] = text;
for(const [ key, value ] of Object.entries(parsed)) { 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; return parsed;