diff --git a/build/lib/i18n.js b/build/lib/i18n.js
index 6ab4c0f5a30..2e7415cd721 100644
--- a/build/lib/i18n.js
+++ b/build/lib/i18n.js
@@ -101,158 +101,161 @@ class TextModel {
return this._lines;
}
}
-class XLF {
- constructor(project) {
- this.project = project;
- this.buffer = [];
- this.files = Object.create(null);
- this.numberOfMessages = 0;
- }
- toString() {
- this.appendHeader();
- for (let file in this.files) {
- this.appendNewLine(``, 2);
- for (let item of this.files[file]) {
- this.addStringItem(file, item);
- }
- this.appendNewLine('', 2);
+let XLF = /** @class */ (() => {
+ class XLF {
+ constructor(project) {
+ this.project = project;
+ this.buffer = [];
+ this.files = Object.create(null);
+ this.numberOfMessages = 0;
}
- this.appendFooter();
- return this.buffer.join('\r\n');
- }
- addFile(original, keys, messages) {
- if (keys.length === 0) {
- console.log('No keys in ' + original);
- return;
- }
- if (keys.length !== messages.length) {
- throw new Error(`Unmatching keys(${keys.length}) and messages(${messages.length}).`);
- }
- this.numberOfMessages += keys.length;
- this.files[original] = [];
- let existingKeys = new Set();
- for (let i = 0; i < keys.length; i++) {
- let key = keys[i];
- let realKey;
- let comment;
- if (Is.string(key)) {
- realKey = key;
- comment = undefined;
- }
- else if (LocalizeInfo.is(key)) {
- realKey = key.key;
- if (key.comment && key.comment.length > 0) {
- comment = key.comment.map(comment => encodeEntities(comment)).join('\r\n');
+ toString() {
+ this.appendHeader();
+ for (let file in this.files) {
+ this.appendNewLine(``, 2);
+ for (let item of this.files[file]) {
+ this.addStringItem(file, item);
}
+ this.appendNewLine('', 2);
}
- if (!realKey || existingKeys.has(realKey)) {
- continue;
+ this.appendFooter();
+ return this.buffer.join('\r\n');
+ }
+ addFile(original, keys, messages) {
+ if (keys.length === 0) {
+ console.log('No keys in ' + original);
+ return;
}
- existingKeys.add(realKey);
- let message = encodeEntities(messages[i]);
- this.files[original].push({ id: realKey, message: message, comment: comment });
+ if (keys.length !== messages.length) {
+ throw new Error(`Unmatching keys(${keys.length}) and messages(${messages.length}).`);
+ }
+ this.numberOfMessages += keys.length;
+ this.files[original] = [];
+ let existingKeys = new Set();
+ for (let i = 0; i < keys.length; i++) {
+ let key = keys[i];
+ let realKey;
+ let comment;
+ if (Is.string(key)) {
+ realKey = key;
+ comment = undefined;
+ }
+ else if (LocalizeInfo.is(key)) {
+ realKey = key.key;
+ if (key.comment && key.comment.length > 0) {
+ comment = key.comment.map(comment => encodeEntities(comment)).join('\r\n');
+ }
+ }
+ if (!realKey || existingKeys.has(realKey)) {
+ continue;
+ }
+ existingKeys.add(realKey);
+ let message = encodeEntities(messages[i]);
+ this.files[original].push({ id: realKey, message: message, comment: comment });
+ }
+ }
+ addStringItem(file, item) {
+ if (!item.id || item.message === undefined || item.message === null) {
+ throw new Error(`No item ID or value specified: ${JSON.stringify(item)}. File: ${file}`);
+ }
+ if (item.message.length === 0) {
+ log(`Item with id ${item.id} in file ${file} has an empty message.`);
+ }
+ this.appendNewLine(``, 4);
+ this.appendNewLine(`${item.message}`, 6);
+ if (item.comment) {
+ this.appendNewLine(`${item.comment}`, 6);
+ }
+ this.appendNewLine('', 4);
+ }
+ appendHeader() {
+ this.appendNewLine('', 0);
+ this.appendNewLine('', 0);
+ }
+ appendFooter() {
+ this.appendNewLine('', 0);
+ }
+ appendNewLine(content, indent) {
+ let line = new Line(indent);
+ line.append(content);
+ this.buffer.push(line.toString());
}
}
- addStringItem(file, item) {
- if (!item.id || item.message === undefined || item.message === null) {
- throw new Error(`No item ID or value specified: ${JSON.stringify(item)}. File: ${file}`);
- }
- if (item.message.length === 0) {
- log(`Item with id ${item.id} in file ${file} has an empty message.`);
- }
- this.appendNewLine(``, 4);
- this.appendNewLine(`${item.message}`, 6);
- if (item.comment) {
- this.appendNewLine(`${item.comment}`, 6);
- }
- this.appendNewLine('', 4);
- }
- appendHeader() {
- this.appendNewLine('', 0);
- this.appendNewLine('', 0);
- }
- appendFooter() {
- this.appendNewLine('', 0);
- }
- appendNewLine(content, indent) {
- let line = new Line(indent);
- line.append(content);
- this.buffer.push(line.toString());
- }
-}
+ XLF.parsePseudo = function (xlfString) {
+ return new Promise((resolve) => {
+ let parser = new xml2js.Parser();
+ let files = [];
+ parser.parseString(xlfString, function (_err, result) {
+ const fileNodes = result['xliff']['file'];
+ fileNodes.forEach(file => {
+ const originalFilePath = file.$.original;
+ const messages = {};
+ const transUnits = file.body[0]['trans-unit'];
+ if (transUnits) {
+ transUnits.forEach((unit) => {
+ const key = unit.$.id;
+ const val = pseudify(unit.source[0]['_'].toString());
+ if (key && val) {
+ messages[key] = decodeEntities(val);
+ }
+ });
+ files.push({ messages: messages, originalFilePath: originalFilePath, language: 'ps' });
+ }
+ });
+ resolve(files);
+ });
+ });
+ };
+ XLF.parse = function (xlfString) {
+ return new Promise((resolve, reject) => {
+ let parser = new xml2js.Parser();
+ let files = [];
+ parser.parseString(xlfString, function (err, result) {
+ if (err) {
+ reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`));
+ }
+ const fileNodes = result['xliff']['file'];
+ if (!fileNodes) {
+ reject(new Error(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`));
+ }
+ fileNodes.forEach((file) => {
+ const originalFilePath = file.$.original;
+ if (!originalFilePath) {
+ reject(new Error(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`));
+ }
+ let language = file.$['target-language'];
+ if (!language) {
+ reject(new Error(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`));
+ }
+ const messages = {};
+ const transUnits = file.body[0]['trans-unit'];
+ if (transUnits) {
+ transUnits.forEach((unit) => {
+ const key = unit.$.id;
+ if (!unit.target) {
+ return; // No translation available
+ }
+ let val = unit.target[0];
+ if (typeof val !== 'string') {
+ 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.`));
+ }
+ });
+ files.push({ messages: messages, originalFilePath: originalFilePath, language: language.toLowerCase() });
+ }
+ });
+ resolve(files);
+ });
+ });
+ };
+ return XLF;
+})();
exports.XLF = XLF;
-XLF.parsePseudo = function (xlfString) {
- return new Promise((resolve) => {
- let parser = new xml2js.Parser();
- let files = [];
- parser.parseString(xlfString, function (_err, result) {
- const fileNodes = result['xliff']['file'];
- fileNodes.forEach(file => {
- const originalFilePath = file.$.original;
- const messages = {};
- const transUnits = file.body[0]['trans-unit'];
- if (transUnits) {
- transUnits.forEach((unit) => {
- const key = unit.$.id;
- const val = pseudify(unit.source[0]['_'].toString());
- if (key && val) {
- messages[key] = decodeEntities(val);
- }
- });
- files.push({ messages: messages, originalFilePath: originalFilePath, language: 'ps' });
- }
- });
- resolve(files);
- });
- });
-};
-XLF.parse = function (xlfString) {
- return new Promise((resolve, reject) => {
- let parser = new xml2js.Parser();
- let files = [];
- parser.parseString(xlfString, function (err, result) {
- if (err) {
- reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`));
- }
- const fileNodes = result['xliff']['file'];
- if (!fileNodes) {
- reject(new Error(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`));
- }
- fileNodes.forEach((file) => {
- const originalFilePath = file.$.original;
- if (!originalFilePath) {
- reject(new Error(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`));
- }
- let language = file.$['target-language'];
- if (!language) {
- reject(new Error(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`));
- }
- const messages = {};
- const transUnits = file.body[0]['trans-unit'];
- if (transUnits) {
- transUnits.forEach((unit) => {
- const key = unit.$.id;
- if (!unit.target) {
- return; // No translation available
- }
- let val = unit.target[0];
- if (typeof val !== 'string') {
- 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.`));
- }
- });
- files.push({ messages: messages, originalFilePath: originalFilePath, language: language.toLowerCase() });
- }
- });
- resolve(files);
- });
- });
-};
class Limiter {
constructor(maxDegreeOfParalellism) {
this.maxDegreeOfParalellism = maxDegreeOfParalellism;
diff --git a/build/package.json b/build/package.json
index 273be58a826..ecff6c7a182 100644
--- a/build/package.json
+++ b/build/package.json
@@ -44,7 +44,7 @@
"minimist": "^1.2.3",
"request": "^2.85.0",
"terser": "4.3.8",
- "typescript": "^4.0.0-dev.20200605",
+ "typescript": "^3.9.3",
"vsce": "1.48.0",
"vscode-telemetry-extractor": "^1.5.4",
"xml2js": "^0.4.17"
diff --git a/build/yarn.lock b/build/yarn.lock
index 89f29ad6d4b..8f615cb4e6c 100644
--- a/build/yarn.lock
+++ b/build/yarn.lock
@@ -2519,10 +2519,10 @@ typescript@^3.0.1:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
-typescript@^4.0.0-dev.20200605:
- version "4.0.0-dev.20200605"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.0-dev.20200605.tgz#a8c587deb99eb3438550cc0f8452535155edf084"
- integrity sha512-4gCtCfq0DiLmGuGq9datahr0nJpnU8GFAwH4USv8i43gU6U/B/dx3KuD7d1mHHvof9zaQXrXe/WIvKiufnxv9A==
+typescript@^3.9.3:
+ version "3.9.3"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.3.tgz#d3ac8883a97c26139e42df5e93eeece33d610b8a"
+ integrity sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==
typical@^4.0.0:
version "4.0.0"
diff --git a/package.json b/package.json
index 242c0fd6e03..a97677e4cf8 100644
--- a/package.json
+++ b/package.json
@@ -154,7 +154,7 @@
"source-map": "^0.4.4",
"style-loader": "^1.0.0",
"ts-loader": "^4.4.2",
- "typescript": "^4.0.0-dev.20200605",
+ "typescript": "^3.9.3",
"typescript-formatter": "7.1.0",
"underscore": "^1.8.2",
"vinyl": "^2.0.0",
diff --git a/yarn.lock b/yarn.lock
index 2a0ded76c01..dd88c0485c9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9270,10 +9270,10 @@ typescript@^2.6.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
integrity sha1-PFtv1/beCRQmkCfwPAlGdY92c6Q=
-typescript@^4.0.0-dev.20200605:
- version "4.0.0-dev.20200605"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.0-dev.20200605.tgz#a8c587deb99eb3438550cc0f8452535155edf084"
- integrity sha512-4gCtCfq0DiLmGuGq9datahr0nJpnU8GFAwH4USv8i43gU6U/B/dx3KuD7d1mHHvof9zaQXrXe/WIvKiufnxv9A==
+typescript@^3.9.3:
+ version "3.9.3"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.3.tgz#d3ac8883a97c26139e42df5e93eeece33d610b8a"
+ integrity sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==
uc.micro@^1.0.1, uc.micro@^1.0.3:
version "1.0.3"