diff --git a/language/LocaleLoader.js b/language/LocaleLoader.js index 5b06f98..e986c42 100644 --- a/language/LocaleLoader.js +++ b/language/LocaleLoader.js @@ -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;