Skip to content

Commit

Permalink
Added small fix for locFunc (microsoft#18364)
Browse files Browse the repository at this point in the history
  • Loading branch information
smartguest authored Feb 15, 2022
1 parent 45763e1 commit 9a28d47
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
19 changes: 14 additions & 5 deletions build/lib/locFunc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ const File = require("vinyl");
const rimraf = require("rimraf");
const gulp = require("gulp");
const vfs = require("vinyl-fs");
/**
* If you need to compile this file for any changes, please run: yarn tsc -p ./build/tsconfig.json
*/
//List of extensions that we changed from vscode, so we can exclude them from having "Microsoft." appended in front.
const alteredVSCodeExtensions = [
'git'
];
const root = path.dirname(path.dirname(__dirname));
// Modified packageLocalExtensionsStream from extensions.ts, but for langpacks.
function packageLangpacksStream() {
Expand Down Expand Up @@ -134,10 +141,13 @@ function modifyI18nPackFiles(existingTranslationFolder, resultingTranslationPath
for (let extension in extensionsPacks) {
const translatedExtFile = i18n.createI18nFile(`extensions/${extension}`, extensionsPacks[extension]);
this.queue(translatedExtFile);
//handle edge case for 'Microsoft.sqlservernotebook' where extension name is the same as extension ID.
//(Other extensions need to have publisher appended in front as their ID.)
const adsExtensionId = (extension === 'Microsoft.sqlservernotebook') ? extension : 'Microsoft.' + extension;
resultingTranslationPaths.push({ id: adsExtensionId, resourceName: `extensions/${extension}.i18n.json` });
// exclude altered vscode extensions from having a new path even if we provide a new I18n file.
if (alteredVSCodeExtensions.indexOf(extension) === -1) {
//handle edge case for 'Microsoft.sqlservernotebook' where extension name is the same as extension ID.
//(Other extensions need to have publisher appended in front as their ID.)
let adsExtensionId = (extension === 'Microsoft.sqlservernotebook') ? extension : 'Microsoft.' + extension;
resultingTranslationPaths.push({ id: adsExtensionId, resourceName: `extensions/${extension}.i18n.json` });
}
}
this.queue(null);
})
Expand All @@ -162,7 +172,6 @@ const VSCODEExtensions = [
"bat",
"configuration-editing",
"docker",
"extension-editing",
"git-ui",
"git",
"github-authentication",
Expand Down
25 changes: 19 additions & 6 deletions build/lib/locFunc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ import * as rimraf from 'rimraf';
import * as gulp from 'gulp';
import * as vfs from 'vinyl-fs';

/**
* If you need to compile this file for any changes, please run: yarn tsc -p ./build/tsconfig.json
*/

//List of extensions that we changed from vscode, so we can exclude them from having "Microsoft." appended in front.
const alteredVSCodeExtensions = [
'git'
]

const root = path.dirname(path.dirname(__dirname));

// Modified packageLocalExtensionsStream from extensions.ts, but for langpacks.
Expand Down Expand Up @@ -68,7 +77,7 @@ function updateMainI18nFile(existingTranslationFilePath: string, originalFilePat

// Delete any SQL strings that are no longer part of ADS in current langpack.
for (let contentKey of Object.keys(objectContents)) {
if(contentKey.startsWith('sql') && messages.contents[contentKey] === undefined){
if (contentKey.startsWith('sql') && messages.contents[contentKey] === undefined) {
delete objectContents[`${contentKey}`]
}
}
Expand Down Expand Up @@ -148,10 +157,14 @@ export function modifyI18nPackFiles(existingTranslationFolder: string, resulting
const translatedExtFile = i18n.createI18nFile(`extensions/${extension}`, extensionsPacks[extension]);
this.queue(translatedExtFile);

//handle edge case for 'Microsoft.sqlservernotebook' where extension name is the same as extension ID.
//(Other extensions need to have publisher appended in front as their ID.)
const adsExtensionId = (extension === 'Microsoft.sqlservernotebook') ? extension : 'Microsoft.' + extension;
resultingTranslationPaths.push({ id: adsExtensionId, resourceName: `extensions/${extension}.i18n.json` });
// exclude altered vscode extensions from having a new path even if we provide a new I18n file.
if (alteredVSCodeExtensions.indexOf(extension) === -1) {
//handle edge case for 'Microsoft.sqlservernotebook' where extension name is the same as extension ID.
//(Other extensions need to have publisher appended in front as their ID.)
let adsExtensionId = (extension === 'Microsoft.sqlservernotebook') ? extension : 'Microsoft.' + extension;

resultingTranslationPaths.push({ id: adsExtensionId, resourceName: `extensions/${extension}.i18n.json` });
}
}
this.queue(null);
})
Expand Down Expand Up @@ -399,7 +412,7 @@ export function renameVscodeLangpacks(): Promise<void> {

//Copy files to vscode langpack, then remove the ADS langpack, and finally rename the vscode langpack to match the ADS one.
globMDArray.forEach(element => {
fs.copyFileSync(element, path.join(locVSCODEFolder,path.parse(element).base));
fs.copyFileSync(element, path.join(locVSCODEFolder, path.parse(element).base));
});
rimraf.sync(locADSFolder);
fs.renameSync(locVSCODEFolder, locADSFolder);
Expand Down

0 comments on commit 9a28d47

Please sign in to comment.