You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reject(newError(`XLF parsing error: Failed to parse XLIFF string. ${err}`));
216
+
}
217
+
constfileNodes=result['xliff']['file'];
218
+
if(!fileNodes){
219
+
reject(newError(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`));
220
+
}
221
+
fileNodes.forEach((file)=>{
222
+
constoriginalFilePath=file.$.original;
223
+
if(!originalFilePath){
224
+
reject(newError(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`));
216
225
}
217
-
constfileNodes=result['xliff']['file'];
218
-
if(!fileNodes){
219
-
reject(newError(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`));
226
+
letlanguage=file.$['target-language'];
227
+
if(!language){
228
+
reject(newError(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`));
229
+
}
230
+
constmessages={};
231
+
consttransUnits=file.body[0]['trans-unit'];
232
+
if(transUnits){
233
+
transUnits.forEach((unit)=>{
234
+
constkey=unit.$.id;
235
+
if(!unit.target){
236
+
return;// No translation available
237
+
}
238
+
letval=unit.target[0];
239
+
if(typeofval!=='string'){
240
+
val=val._;
241
+
}
242
+
if(key&&val){
243
+
messages[key]=decodeEntities(val);
244
+
}
245
+
else{
246
+
reject(newError(`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.`));
reject(newError(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`));
225
-
}
226
-
letlanguage=file.$['target-language'];
227
-
if(!language){
228
-
reject(newError(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`));
229
-
}
230
-
constmessages={};
231
-
consttransUnits=file.body[0]['trans-unit'];
232
-
if(transUnits){
233
-
transUnits.forEach((unit)=>{
234
-
constkey=unit.$.id;
235
-
if(!unit.target){
236
-
return;// No translation available
237
-
}
238
-
letval=unit.target[0];
239
-
if(typeofval!=='string'){
240
-
val=val._;
241
-
}
242
-
if(key&&val){
243
-
messages[key]=decodeEntities(val);
244
-
}
245
-
else{
246
-
reject(newError(`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.`));
0 commit comments