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;
|
return;
|
||||||
}
|
}
|
||||||
const fileContent = fs.readFileSync(file).toString();
|
const fileContent = fs.readFileSync(file).toString();
|
||||||
|
|
||||||
const json = convert.xml2js(fileContent, options);
|
const json = convert.xml2js(fileContent, options);
|
||||||
|
|
||||||
const doctype = json["_doctype"];
|
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}...`)
|
console.log(`Modying ${language}...`)
|
||||||
messages.forEach(message => {
|
messages.forEach(message => {
|
||||||
|
|
Loading…
Reference in New Issue