mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Fixed gulp task termination before all translations were emitted. Fixed issue with incorrect encoding for pulled translations.
This commit is contained in:
@@ -13,7 +13,7 @@ var xml2js = require("xml2js");
|
||||
var glob = require("glob");
|
||||
var http = require("http");
|
||||
var util = require('gulp-util');
|
||||
var iconv = require('iconv-lite');
|
||||
var Iconv = require('iconv').Iconv;
|
||||
function log(message) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
@@ -889,11 +889,11 @@ function retrieveResource(language, resource, apiHostname, credentials) {
|
||||
method: 'GET'
|
||||
};
|
||||
var request = http.request(options, function (res) {
|
||||
var xlfBuffer = '';
|
||||
res.on('data', function (data) { return xlfBuffer += data; });
|
||||
var xlfBuffer = [];
|
||||
res.on('data', function (chunk) { return xlfBuffer.push(chunk); });
|
||||
res.on('end', function () {
|
||||
if (res.statusCode === 200) {
|
||||
resolve(new File({ contents: new Buffer(xlfBuffer), path: project + "/" + iso639_2_to_3[language] + "/" + slug + ".xlf" }));
|
||||
resolve(new File({ contents: Buffer.concat(xlfBuffer), path: project + "/" + iso639_2_to_3[language] + "/" + slug + ".xlf" }));
|
||||
}
|
||||
reject(slug + " in " + project + " returned no data. Response code: " + res.statusCode + ".");
|
||||
});
|
||||
@@ -905,9 +905,12 @@ function retrieveResource(language, resource, apiHostname, credentials) {
|
||||
});
|
||||
}
|
||||
function prepareJsonFiles() {
|
||||
var parsePromises = [];
|
||||
return event_stream_1.through(function (xlf) {
|
||||
var stream = this;
|
||||
XLF.parse(xlf.contents.toString()).then(function (resolvedFiles) {
|
||||
var parsePromise = XLF.parse(xlf.contents.toString());
|
||||
parsePromises.push(parsePromise);
|
||||
parsePromise.then(function (resolvedFiles) {
|
||||
resolvedFiles.forEach(function (file) {
|
||||
var messages = file.messages, translatedFile;
|
||||
// ISL file path always starts with 'build/'
|
||||
@@ -926,6 +929,11 @@ function prepareJsonFiles() {
|
||||
}, function (rejectReason) {
|
||||
throw new Error("XLF parsing error: " + rejectReason);
|
||||
});
|
||||
}, function () {
|
||||
var _this = this;
|
||||
Promise.all(parsePromises)
|
||||
.then(function () { _this.emit('end'); })
|
||||
.catch(function (reason) { throw new Error(reason); });
|
||||
});
|
||||
}
|
||||
exports.prepareJsonFiles = prepareJsonFiles;
|
||||
@@ -942,7 +950,6 @@ function createI18nFile(base, originalFilePath, messages) {
|
||||
contents: new Buffer(content, 'utf8')
|
||||
});
|
||||
}
|
||||
exports.createI18nFile = createI18nFile;
|
||||
var languageNames = {
|
||||
'chs': 'Simplified Chinese',
|
||||
'cht': 'Traditional Chinese',
|
||||
@@ -1012,12 +1019,12 @@ function createIslFile(base, originalFilePath, messages, language) {
|
||||
var tag = iso639_3_to_2[language];
|
||||
var basename = path.basename(originalFilePath);
|
||||
var filePath = path.join(base, path.dirname(originalFilePath), basename) + "." + tag + ".isl";
|
||||
var iconv = new Iconv('UTF-8', encodings[language]);
|
||||
return new File({
|
||||
path: filePath,
|
||||
contents: iconv.encode(new Buffer(content.join('\r\n'), 'utf8'), encodings[language])
|
||||
contents: iconv.convert(new Buffer(content.join('\r\n'), 'utf8'))
|
||||
});
|
||||
}
|
||||
exports.createIslFile = createIslFile;
|
||||
function encodeEntities(value) {
|
||||
var result = [];
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
@@ -1041,4 +1048,3 @@ function encodeEntities(value) {
|
||||
function decodeEntities(value) {
|
||||
return value.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');
|
||||
}
|
||||
exports.decodeEntities = decodeEntities;
|
||||
|
||||
Reference in New Issue
Block a user