mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
69
build/npm/update-localization-extension.js
Normal file
69
build/npm/update-localization-extension.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
let i18n = require("../lib/i18n");
|
||||
|
||||
let fs = require("fs");
|
||||
let path = require("path");
|
||||
let vfs = require("vinyl-fs");
|
||||
let rimraf = require('rimraf');
|
||||
|
||||
function update(idOrPath) {
|
||||
if (!idOrPath) {
|
||||
throw new Error('Argument must be the location of the localization extension.');
|
||||
}
|
||||
let locExtFolder = idOrPath;
|
||||
if (/^\w{2}(-\w+)?$/.test(idOrPath)) {
|
||||
locExtFolder = '../vscode-language-pack-' + idOrPath;
|
||||
}
|
||||
let locExtStat = fs.statSync(locExtFolder);
|
||||
if (!locExtStat || !locExtStat.isDirectory) {
|
||||
throw new Error('No directory found at ' + idOrPath);
|
||||
}
|
||||
let packageJSON = JSON.parse(fs.readFileSync(path.join(locExtFolder, 'package.json')).toString());
|
||||
let contributes = packageJSON['contributes'];
|
||||
if (!contributes) {
|
||||
throw new Error('The extension must define a "localizations" contribution in the "package.json"');
|
||||
}
|
||||
let localizations = contributes['localizations'];
|
||||
if (!localizations) {
|
||||
throw new Error('The extension must define a "localizations" contribution of type array in the "package.json"');
|
||||
}
|
||||
|
||||
localizations.forEach(function (localization) {
|
||||
if (!localization.languageId || !localization.languageName || !localization.localizedLanguageName) {
|
||||
throw new Error('Each localization contribution must define "languageId", "languageName" and "localizedLanguageName" properties.');
|
||||
}
|
||||
let server = localization.server || 'www.transifex.com';
|
||||
let userName = localization.userName || 'api';
|
||||
let apiToken = process.env.TRANSIFEX_API_TOKEN;
|
||||
let languageId = localization.transifexId || localization.languageId;
|
||||
let translationDataFolder = path.join(locExtFolder, 'translations');
|
||||
|
||||
if (fs.existsSync(translationDataFolder) && fs.existsSync(path.join(translationDataFolder, 'main.i18n.json'))) {
|
||||
console.log('Clearing \'' + translationDataFolder + '\'...');
|
||||
rimraf.sync(translationDataFolder);
|
||||
}
|
||||
|
||||
console.log('Downloading translations for \'' + languageId + '\' to \'' + translationDataFolder + '\'...');
|
||||
const translationPaths = [];
|
||||
i18n.pullI18nPackFiles(server, userName, apiToken, { id: languageId }, translationPaths)
|
||||
.pipe(vfs.dest(translationDataFolder)).on('end', function () {
|
||||
localization.translations = [];
|
||||
for (let tp of translationPaths) {
|
||||
localization.translations.push({ id: tp.id, path: `./translations/${tp.resourceName}`});
|
||||
}
|
||||
fs.writeFileSync(path.join(locExtFolder, 'package.json'), JSON.stringify(packageJSON, null, '\t'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
if (path.basename(process.argv[1]) === 'update-localization-extension.js') {
|
||||
update(process.argv[2]);
|
||||
}
|
||||
Reference in New Issue
Block a user