提交 fb4a49b0 编写于 作者: M Michel Kaporin

Target only core languages for the stable build. Ref #27818

上级 ab692310
......@@ -84,6 +84,11 @@ const BUNDLED_FILE_HEADER = [
' *--------------------------------------------------------*/'
].join('\n');
var languages = ['chs', 'cht', 'jpn', 'kor', 'deu', 'fra', 'esn', 'rus', 'ita'];
if (product.quality !== 'stable') {
languages = languages.concat(['ptb']); // Add languages requested by the community to non-stable builds
}
gulp.task('clean-optimized-vscode', util.rimraf('out-vscode'));
gulp.task('optimize-vscode', ['clean-optimized-vscode', 'compile-build', 'compile-extensions-build'], common.optimizeTask({
entryPoints: vscodeEntryPoints,
......@@ -91,7 +96,8 @@ gulp.task('optimize-vscode', ['clean-optimized-vscode', 'compile-build', 'compil
resources: vscodeResources,
loaderConfig: common.loaderConfig(nodeModules),
header: BUNDLED_FILE_HEADER,
out: 'out-vscode'
out: 'out-vscode',
languages: languages
}));
......@@ -158,10 +164,6 @@ gulp.task('electron', ['clean-electron'], getElectron(process.arch));
gulp.task('electron-ia32', ['clean-electron'], getElectron('ia32'));
gulp.task('electron-x64', ['clean-electron'], getElectron('x64'));
var languages = ['chs', 'cht', 'jpn', 'kor', 'deu', 'fra', 'esn', 'rus', 'ita'];
if (product.quality !== 'stable') {
languages.concat(['ptb']);
}
/**
* Compute checksums for some files.
......
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var path = require("path");
var fs = require("fs");
......@@ -207,17 +207,6 @@ XLF.parse = function (xlfString) {
});
};
exports.XLF = XLF;
var vscodeLanguages = [
'chs',
'cht',
'jpn',
'kor',
'deu',
'fra',
'esn',
'rus',
'ita'
];
var iso639_3_to_2 = {
'chs': 'zh-cn',
'cht': 'zh-tw',
......@@ -347,7 +336,7 @@ function escapeCharacters(value) {
}
return result.join('');
}
function processCoreBundleFormat(fileHeader, json, emitter) {
function processCoreBundleFormat(fileHeader, languages, json, emitter) {
var keysSection = json.keys;
var messageSection = json.messages;
var bundleSection = json.bundles;
......@@ -375,8 +364,14 @@ function processCoreBundleFormat(fileHeader, json, emitter) {
});
});
var languageDirectory = path.join(__dirname, '..', '..', 'i18n');
var languages = sortLanguages(fs.readdirSync(languageDirectory).filter(function (item) { return fs.statSync(path.join(languageDirectory, item)).isDirectory(); }));
languages.forEach(function (language) {
var languageDirs;
if (languageDirs) {
languageDirs = sortLanguages(languages);
}
else {
languageDirs = sortLanguages(fs.readdirSync(languageDirectory).filter(function (item) { return fs.statSync(path.join(languageDirectory, item)).isDirectory(); }));
}
languageDirs.forEach(function (language) {
if (!language.iso639_2) {
return;
}
......@@ -448,7 +443,7 @@ function processCoreBundleFormat(fileHeader, json, emitter) {
var value = statistics[key];
log(key + " has " + value + " untranslated strings.");
});
vscodeLanguages.forEach(function (language) {
languageDirs.forEach(function (language) {
var iso639_2 = iso639_3_to_2[language];
if (!iso639_2) {
log("\tCouldn't find iso639 2 mapping for language " + language + ". Using default language instead.");
......@@ -473,7 +468,7 @@ function processNlsFiles(opts) {
this.emit('error', "Failed to read component file: " + file.relative);
}
if (BundledFormat.is(json)) {
processCoreBundleFormat(opts.fileHeader, json, this);
processCoreBundleFormat(opts.fileHeader, opts.languages, json, this);
}
}
this.emit('data', file);
......
......@@ -272,18 +272,6 @@ export class XLF {
};
}
const vscodeLanguages: string[] = [
'chs',
'cht',
'jpn',
'kor',
'deu',
'fra',
'esn',
'rus',
'ita'
];
const iso639_3_to_2: Map<string> = {
'chs': 'zh-cn',
'cht': 'zh-tw',
......@@ -420,7 +408,7 @@ function escapeCharacters(value: string): string {
return result.join('');
}
function processCoreBundleFormat(fileHeader: string, json: BundledFormat, emitter: any) {
function processCoreBundleFormat(fileHeader: string, languages: string[], json: BundledFormat, emitter: any) {
let keysSection = json.keys;
let messageSection = json.messages;
let bundleSection = json.bundles;
......@@ -450,8 +438,13 @@ function processCoreBundleFormat(fileHeader: string, json: BundledFormat, emitte
});
let languageDirectory = path.join(__dirname, '..', '..', 'i18n');
let languages = sortLanguages(fs.readdirSync(languageDirectory).filter((item) => fs.statSync(path.join(languageDirectory, item)).isDirectory()));
languages.forEach((language) => {
let languageDirs;
if (languageDirs) {
languageDirs = sortLanguages(languages);
} else {
languageDirs = sortLanguages(fs.readdirSync(languageDirectory).filter((item) => fs.statSync(path.join(languageDirectory, item)).isDirectory()));
}
languageDirs.forEach((language) => {
if (!language.iso639_2) {
return;
}
......@@ -523,7 +516,7 @@ function processCoreBundleFormat(fileHeader: string, json: BundledFormat, emitte
let value = statistics[key];
log(`${key} has ${value} untranslated strings.`);
});
vscodeLanguages.forEach(language => {
languageDirs.forEach(language => {
let iso639_2 = iso639_3_to_2[language];
if (!iso639_2) {
log(`\tCouldn't find iso639 2 mapping for language ${language}. Using default language instead.`);
......@@ -536,7 +529,7 @@ function processCoreBundleFormat(fileHeader: string, json: BundledFormat, emitte
});
}
export function processNlsFiles(opts: { fileHeader: string; }): ThroughStream {
export function processNlsFiles(opts: { fileHeader: string; languages: string[] }): ThroughStream {
return through(function (file: File) {
let fileName = path.basename(file.path);
if (fileName === 'nls.metadata.json') {
......@@ -547,7 +540,7 @@ export function processNlsFiles(opts: { fileHeader: string; }): ThroughStream {
this.emit('error', `Failed to read component file: ${file.relative}`);
}
if (BundledFormat.is(json)) {
processCoreBundleFormat(opts.fileHeader, json, this);
processCoreBundleFormat(opts.fileHeader, opts.languages, json, this);
}
}
this.emit('data', file);
......
......@@ -163,7 +163,8 @@ function optimizeTask(opts) {
includeContent: true
}))
.pipe(i18n.processNlsFiles({
fileHeader: bundledFileHeader
fileHeader: bundledFileHeader,
languages: opts.languages
}))
.pipe(gulp.dest(out));
};
......
......@@ -158,6 +158,10 @@ export interface IOptimizeTaskOpts {
* (out folder name)
*/
out: string;
/**
* (languages to process)
*/
languages: string[];
}
export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStream {
const entryPoints = opts.entryPoints;
......@@ -228,7 +232,8 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
includeContent: true
}))
.pipe(i18n.processNlsFiles({
fileHeader: bundledFileHeader
fileHeader: bundledFileHeader,
languages: opts.languages
}))
.pipe(gulp.dest(out));
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册