mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Update to build using TS 4.0-nightly
This commit is contained in:
parent
70a3cb373d
commit
5865db6ca8
|
@ -101,161 +101,158 @@ class TextModel {
|
|||
return this._lines;
|
||||
}
|
||||
}
|
||||
let XLF = /** @class */ (() => {
|
||||
class XLF {
|
||||
constructor(project) {
|
||||
this.project = project;
|
||||
this.buffer = [];
|
||||
this.files = Object.create(null);
|
||||
this.numberOfMessages = 0;
|
||||
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(`<file original="${file}" source-language="en" datatype="plaintext"><body>`, 2);
|
||||
for (let item of this.files[file]) {
|
||||
this.addStringItem(file, item);
|
||||
}
|
||||
this.appendNewLine('</body></file>', 2);
|
||||
}
|
||||
toString() {
|
||||
this.appendHeader();
|
||||
for (let file in this.files) {
|
||||
this.appendNewLine(`<file original="${file}" source-language="en" datatype="plaintext"><body>`, 2);
|
||||
for (let item of this.files[file]) {
|
||||
this.addStringItem(file, item);
|
||||
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');
|
||||
}
|
||||
this.appendNewLine('</body></file>', 2);
|
||||
}
|
||||
this.appendFooter();
|
||||
return this.buffer.join('\r\n');
|
||||
}
|
||||
addFile(original, keys, messages) {
|
||||
if (keys.length === 0) {
|
||||
console.log('No keys in ' + original);
|
||||
return;
|
||||
if (!realKey || existingKeys.has(realKey)) {
|
||||
continue;
|
||||
}
|
||||
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(`<trans-unit id="${item.id}">`, 4);
|
||||
this.appendNewLine(`<source xml:lang="en">${item.message}</source>`, 6);
|
||||
if (item.comment) {
|
||||
this.appendNewLine(`<note>${item.comment}</note>`, 6);
|
||||
}
|
||||
this.appendNewLine('</trans-unit>', 4);
|
||||
}
|
||||
appendHeader() {
|
||||
this.appendNewLine('<?xml version="1.0" encoding="utf-8"?>', 0);
|
||||
this.appendNewLine('<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">', 0);
|
||||
}
|
||||
appendFooter() {
|
||||
this.appendNewLine('</xliff>', 0);
|
||||
}
|
||||
appendNewLine(content, indent) {
|
||||
let line = new Line(indent);
|
||||
line.append(content);
|
||||
this.buffer.push(line.toString());
|
||||
existingKeys.add(realKey);
|
||||
let message = encodeEntities(messages[i]);
|
||||
this.files[original].push({ id: realKey, message: message, comment: comment });
|
||||
}
|
||||
}
|
||||
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;
|
||||
})();
|
||||
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(`<trans-unit id="${item.id}">`, 4);
|
||||
this.appendNewLine(`<source xml:lang="en">${item.message}</source>`, 6);
|
||||
if (item.comment) {
|
||||
this.appendNewLine(`<note>${item.comment}</note>`, 6);
|
||||
}
|
||||
this.appendNewLine('</trans-unit>', 4);
|
||||
}
|
||||
appendHeader() {
|
||||
this.appendNewLine('<?xml version="1.0" encoding="utf-8"?>', 0);
|
||||
this.appendNewLine('<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">', 0);
|
||||
}
|
||||
appendFooter() {
|
||||
this.appendNewLine('</xliff>', 0);
|
||||
}
|
||||
appendNewLine(content, indent) {
|
||||
let line = new Line(indent);
|
||||
line.append(content);
|
||||
this.buffer.push(line.toString());
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
"minimist": "^1.2.3",
|
||||
"request": "^2.85.0",
|
||||
"terser": "4.3.8",
|
||||
"typescript": "^3.9.3",
|
||||
"typescript": "^4.0.0-dev.20200605",
|
||||
"vsce": "1.48.0",
|
||||
"vscode-telemetry-extractor": "^1.5.4",
|
||||
"xml2js": "^0.4.17"
|
||||
|
|
|
@ -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@^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==
|
||||
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==
|
||||
|
||||
typical@^4.0.0:
|
||||
version "4.0.0"
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
"source-map": "^0.4.4",
|
||||
"style-loader": "^1.0.0",
|
||||
"ts-loader": "^4.4.2",
|
||||
"typescript": "^3.9.3",
|
||||
"typescript": "^4.0.0-dev.20200605",
|
||||
"typescript-formatter": "7.1.0",
|
||||
"underscore": "^1.8.2",
|
||||
"vinyl": "^2.0.0",
|
||||
|
|
|
@ -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@^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==
|
||||
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==
|
||||
|
||||
uc.micro@^1.0.1, uc.micro@^1.0.3:
|
||||
version "1.0.3"
|
||||
|
|
Loading…
Reference in a new issue