fix(scripts): i18n script shouldn't break because of multi contexts

This commit is contained in:
Pascal Precht 2020-09-14 14:10:08 +02:00 committed by Iuri Matias
parent 6c7a3d6340
commit 7fe2d8696f
1 changed files with 6 additions and 2 deletions

View File

@ -13,7 +13,6 @@ tsFiles.forEach(file => {
return;
}
const fileContent = fs.readFileSync(file).toString();
const json = convert.xml2js(fileContent, options);
const doctype = json["_doctype"];
@ -35,7 +34,12 @@ tsFiles.forEach(file => {
}
}
const messages = json[doctype].context.message;
let messages = []
if (json[doctype].context.length) {
messages = json[doctype].context.flatMap(c => c.message)
} else {
messages = json[doctype].context.message;
}
console.log(`Modying ${language}...`)
messages.forEach(message => {