diff --git a/build/gulpfile.sql.js b/build/gulpfile.sql.js index 8fa94d4831..5b4c042641 100644 --- a/build/gulpfile.sql.js +++ b/build/gulpfile.sql.js @@ -146,4 +146,8 @@ gulp.task('package-rebuild-extensions', task.series( task.define('rebuild-extensions-build', () => ext.packageRebuildExtensionsStream().pipe(gulp.dest('.build'))), )); -gulp.task('refresh-langpacks', () => loc.refreshLangpacks()); +gulp.task('update-langpacks', task.series( + task.define('rename-vscode-packs', () => loc.renameVscodeLangpacks()), + task.define('refresh-langpack-resources', () => loc.refreshLangpacks()) +)); + diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 8c56961d59..fcf28038fb 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -108,16 +108,48 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series( )); gulp.task(optimizeVSCodeTask); -// {{SQL CARBON EDIT}} Gulp task that exports any extensions found in the build folder as an XLF to an external folder. -const exportXLFFolderTask = task.define('export-xlf-folder', - function () { - const pathToExtensions = '.build/extensions/*'; - return es.merge( - gulp.src(pathToExtensions).pipe(i18n.createXlfFilesForExtensions()) - ).pipe(vfs.dest('../export-xlfs')); - } -); -gulp.task(exportXLFFolderTask); +// {{SQL CARBON EDIT}} Gulp task that imports any relevant ADS XLF found in vscode-translations-export to resources/xlf/en folder. + +// List of ADS extension XLF files that we want to put into the English resource folder. +const extensionsFilter = filter([ + "**/admin-tool-ext-win.xlf", + "**/agent.xlf", + "**/arc.xlf", + "**/asde-deployment.xlf", + "**/azdata.xlf", + "**/azurecore.xlf", + "**/azurehybridtoolkit.xlf", + "**/big-data-cluster.xlf", + "**/cms.xlf", + "**/dacpac.xlf", + "**/data-workspace.xlf", + "**/import.xlf", + "**/kusto.xlf", + "**/machine-learning.xlf", + "**/Microsoft.sqlservernotebook.xlf", + "**/mssql.xlf", + "**/notebook.xlf", + "**/profiler.xlf", + "**/query-history.xlf", + "**/resource-deployment.xlf", + "**/schema-compare.xlf", + "**/server-report.xlf", + "**/sql-assessment.xlf", + "**/sql-database-projects.xlf", + "**/sql-migration.xlf", + "**/xml-language-features.xlf" +]) + +// Copy ADS extension XLFs into English resource folder. +const importExtensionsTask = task.define('import-extensions-xlfs', function () { + return es.merge( + gulp.src(`./vscode-translations-export/vscode-extensions/*.xlf`) + .pipe(extensionsFilter), + gulp.src(`./vscode-translations-export/ads-core/*.xlf`) + ) + .pipe(vfs.dest(`./resources/xlf/en`)); +}); +gulp.task(importExtensionsTask) // {{SQL CARBON EDIT}} end const sourceMappingURLBase = `https://sqlopsbuilds.blob.core.windows.net/sourcemaps/${commit}`; @@ -449,11 +481,12 @@ gulp.task(task.define( ) )); -gulp.task(task.define( +// {{SQL CARBON EDIT}} Allow for gulp task to be added to update-english-xlfs. +const vscodeTranslationsExport = task.define( 'vscode-translations-export', task.series( compileBuildTask, - compileExtensionsBuildTask, + compileLocalizationExtensionsBuildTask, // {{SQL CARBON EDIT}} now include all extensions in ADS, not just a subset. (replaces "compileExtensionsBuildTask" here). optimizeVSCodeTask, function () { const pathToMetadata = './out-vscode/nls.metadata.json'; @@ -464,17 +497,19 @@ gulp.task(task.define( gulp.src(pathToMetadata).pipe(i18n.createXlfFilesForCoreBundle()), gulp.src(pathToSetup).pipe(i18n.createXlfFilesForIsl()), gulp.src(pathToExtensions).pipe(i18n.createXlfFilesForExtensions()) - ).pipe(vfs.dest('../vscode-translations-export')); + ).pipe(vfs.dest('./vscode-translations-export')); // {{SQL CARBON EDIT}} move vscode-translations-export into ADS (for safely deleting after use). } ) -)); +); +gulp.task(vscodeTranslationsExport) -// {{SQL CARBON EDIT}} Localization gulp task, similar to vscode-translations-export but for all extensions. +// {{SQL CARBON EDIT}} Localization gulp task, runs vscodeTranslationsExport and imports a subset of the generated XLFs into the folder. gulp.task(task.define( - 'export-xlfs', + 'update-english-xlfs', task.series( - compileLocalizationExtensionsBuildTask, - exportXLFFolderTask + vscodeTranslationsExport, + importExtensionsTask, + task.define('delete-vscode-translations-export', util.rimraf('./vscode-translations-export')) ) )); // {{SQL CARBON EDIT}} end diff --git a/build/lib/i18n.js b/build/lib/i18n.js index ed591084ea..fba63a3f42 100644 --- a/build/lib/i18n.js +++ b/build/lib/i18n.js @@ -484,7 +484,7 @@ function processNlsFiles(opts) { exports.processNlsFiles = processNlsFiles; const editorProject = 'vscode-editor', workbenchProject = 'vscode-workbench', extensionsProject = 'vscode-extensions', setupProject = 'vscode-setup'; // {{SQL CARBON EDIT}} -const sqlopsProject = 'sqlops-core'; +const adsProject = 'ads-core'; function getResource(sourceFile) { let resource; if (/^vs\/platform/.test(sourceFile)) { @@ -515,7 +515,7 @@ function getResource(sourceFile) { } // {{SQL CARBON EDIT}} else if (/^sql/.test(sourceFile)) { - return { name: 'sql', project: sqlopsProject }; + return { name: 'sql', project: adsProject }; } throw new Error(`Could not identify the XLF bundle for ${sourceFile}`); } diff --git a/build/lib/i18n.ts b/build/lib/i18n.ts index 19a859dade..055b80808d 100644 --- a/build/lib/i18n.ts +++ b/build/lib/i18n.ts @@ -611,7 +611,7 @@ const editorProject: string = 'vscode-editor', setupProject: string = 'vscode-setup'; // {{SQL CARBON EDIT}} -const sqlopsProject: string = 'sqlops-core'; +const adsProject: string = 'ads-core'; export function getResource(sourceFile: string): Resource { let resource: string; @@ -638,7 +638,7 @@ export function getResource(sourceFile: string): Resource { // {{SQL CARBON EDIT}} else if (/^sql/.test(sourceFile)) { - return { name: 'sql', project: sqlopsProject }; + return { name: 'sql', project: adsProject }; } throw new Error(`Could not identify the XLF bundle for ${sourceFile}`); diff --git a/build/lib/locFunc.js b/build/lib/locFunc.js index 4265be9c90..1f06f5e4ca 100644 --- a/build/lib/locFunc.js +++ b/build/lib/locFunc.js @@ -4,7 +4,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); -exports.refreshLangpacks = exports.modifyI18nPackFiles = exports.packageSingleExtensionStream = exports.packageLangpacksStream = void 0; +exports.renameVscodeLangpacks = exports.refreshLangpacks = exports.modifyI18nPackFiles = exports.packageSingleExtensionStream = exports.packageLangpacksStream = void 0; const es = require("event-stream"); const path = require("path"); const glob = require("glob"); @@ -340,3 +340,37 @@ function refreshLangpacks() { return Promise.resolve(); } exports.refreshLangpacks = refreshLangpacks; +/** + * Function for adding replacing ads language packs with vscode ones. + * For new languages, remember to add to i18n.extraLanguages so that it will be recognized by ADS. +*/ +function renameVscodeLangpacks() { + let supportedLocations = [...i18n.defaultLanguages, ...i18n.extraLanguages]; + for (let i = 0; i < supportedLocations.length; i++) { + let langId = supportedLocations[i].id; + if (langId === "zh-cn") { + langId = "zh-hans"; + } + if (langId === "zh-tw") { + langId = "zh-hant"; + } + let locADSFolder = path.join('.', 'i18n', `ads-language-pack-${langId}`); + let locVSCODEFolder = path.join('.', 'i18n', `vscode-language-pack-${langId}`); + try { + fs.statSync(locVSCODEFolder); + } + catch (_a) { + console.log('vscode pack is not in ADS yet: ' + langId); + continue; + } + gulp.src(`i18n/ads-language-pack-${langId}/*.md`) + .pipe(vfs.dest(locVSCODEFolder, { overwrite: true })) + .end(function () { + rimraf.sync(locADSFolder); + fs.renameSync(locVSCODEFolder, locADSFolder); + }); + } + console.log("Langpack Rename Completed."); + return Promise.resolve(); +} +exports.renameVscodeLangpacks = renameVscodeLangpacks; diff --git a/build/lib/locFunc.ts b/build/lib/locFunc.ts index 942eed6a7a..1c448119ca 100644 --- a/build/lib/locFunc.ts +++ b/build/lib/locFunc.ts @@ -362,3 +362,40 @@ export function refreshLangpacks(): Promise { return Promise.resolve(); } +/** + * Function for adding replacing ads language packs with vscode ones. + * For new languages, remember to add to i18n.extraLanguages so that it will be recognized by ADS. +*/ +export function renameVscodeLangpacks(): Promise { + let supportedLocations = [...i18n.defaultLanguages, ...i18n.extraLanguages]; + + + for (let i = 0; i < supportedLocations.length; i++) { + let langId = supportedLocations[i].id; + if (langId === "zh-cn") { + langId = "zh-hans"; + } + if (langId === "zh-tw") { + langId = "zh-hant"; + } + let locADSFolder = path.join('.', 'i18n', `ads-language-pack-${langId}`); + let locVSCODEFolder = path.join('.', 'i18n', `vscode-language-pack-${langId}`); + try { + fs.statSync(locVSCODEFolder); + } + catch { + console.log('vscode pack is not in ADS yet: ' + langId); + continue; + } + gulp.src(`i18n/ads-language-pack-${langId}/*.md`) + .pipe(vfs.dest(locVSCODEFolder, {overwrite: true})) + .end(function () { + rimraf.sync(locADSFolder); + fs.renameSync(locVSCODEFolder, locADSFolder); + }); + } + + console.log("Langpack Rename Completed."); + return Promise.resolve(); +} + diff --git a/build/lib/rollup.js b/build/lib/rollup.js index 93d9954a81..50e27aed37 100644 --- a/build/lib/rollup.js +++ b/build/lib/rollup.js @@ -8,7 +8,7 @@ exports.rollupAngular = void 0; const fs = require("fs"); const rollup = require("rollup"); const path = require("path"); -// getting around stupid import rules +// getting around import rules const nodeResolve = require('rollup-plugin-node-resolve'); const commonjs = require('rollup-plugin-commonjs'); async function rollupModule(options) {