fix(scripts): i18n script shouldn't break because of multi contexts
This commit is contained in:
parent
6c7a3d6340
commit
7fe2d8696f
|
@ -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 => {
|
||||
|
|
Loading…
Reference in New Issue