mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Support empty messages during location import
This commit is contained in:
@@ -237,14 +237,13 @@ XLF.parse = function (xlfString) {
|
||||
}
|
||||
let val = unit.target[0];
|
||||
if (typeof val !== 'string') {
|
||||
val = val._;
|
||||
// We allow empty source values so support them for translations as well.
|
||||
val = val._ ? val._ : '';
|
||||
}
|
||||
if (key && val) {
|
||||
messages[key] = decodeEntities(val);
|
||||
}
|
||||
else {
|
||||
reject(new Error(`XLF parsing error: XLIFF file ${originalFilePath} does not contain full localization data. ID or target translation for one of the trans-unit nodes is not present.`));
|
||||
if (!key) {
|
||||
reject(new Error(`XLF parsing error: trans-unit ${JSON.stringify(unit, undefined, 0)} defined in file ${originalFilePath} is missing the ID attribute.`));
|
||||
}
|
||||
messages[key] = decodeEntities(val);
|
||||
});
|
||||
files.push({ messages: messages, originalFilePath: originalFilePath, language: language.toLowerCase() });
|
||||
}
|
||||
|
||||
@@ -339,13 +339,13 @@ export class XLF {
|
||||
|
||||
let val = unit.target[0];
|
||||
if (typeof val !== 'string') {
|
||||
val = val._;
|
||||
// We allow empty source values so support them for translations as well.
|
||||
val = val._ ? val._ : '';
|
||||
}
|
||||
if (key && val) {
|
||||
messages[key] = decodeEntities(val);
|
||||
} else {
|
||||
reject(new Error(`XLF parsing error: XLIFF file ${originalFilePath} does not contain full localization data. ID or target translation for one of the trans-unit nodes is not present.`));
|
||||
if (!key) {
|
||||
reject(new Error(`XLF parsing error: trans-unit ${JSON.stringify(unit, undefined, 0)} defined in file ${originalFilePath} is missing the ID attribute.`));
|
||||
}
|
||||
messages[key] = decodeEntities(val);
|
||||
});
|
||||
files.push({ messages: messages, originalFilePath: originalFilePath, language: language.toLowerCase() });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user