Skip to content

Commit

Permalink
Prompt user to install language pack
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed May 21, 2018
1 parent 610487a commit 43d48b1
Showing 1 changed file with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import URI from 'vs/base/common/uri';
import { join } from 'vs/base/common/paths';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IStorageService, } from 'vs/platform/storage/common/storage';
import { IStorageService, StorageScope, } from 'vs/platform/storage/common/storage';
import { TPromise } from 'vs/base/common/winjs.base';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { VIEWLET_ID as EXTENSIONS_VIEWLET_ID, IExtensionsViewlet } from 'vs/workbench/parts/extensions/common/extensions';
import product from 'vs/platform/node/product';

// Register action to configure locale and related settings
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
Expand Down Expand Up @@ -111,7 +112,56 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
});
}
});
return;
}

const bundledTranslations = (product['bundledTranslations'] || {})[platform.locale];
if (language === platform.locale || !bundledTranslations) {
return;
}

// The initial value for below dont get used. We just have it here so that they get localized.
// The localized strings get pulled into the "product.json" file during endgame to get shipped
let searchForLanguagePacks = localize('searchForLanguagePacks', "Your locale is not supported by VS Code. There are extensions in the marketplace that can localize VS Code.");
let searchMarketplace = localize('searchMarketplace', "Search Marketplace");
let dontShowAgain = localize('neverAgain', "Don't Show Again");
searchForLanguagePacks = bundledTranslations['searchForLanguagePacks'];
searchMarketplace = bundledTranslations['searchMarketplace'];
dontShowAgain = bundledTranslations['neverAgain'];

const dontShowSearchLanguagePacksAgainKey = 'language.install.donotask';
let dontShowSearchForLanguages = JSON.parse(this.storageService.get(dontShowSearchLanguagePacksAgainKey, StorageScope.GLOBAL, '[]'));
if (!Array.isArray(dontShowSearchForLanguages)) {
dontShowSearchForLanguages = [];
}

if (dontShowSearchForLanguages.indexOf(platform.locale) > -1
|| !searchForLanguagePacks
|| !searchMarketplace
|| !dontShowAgain) {
return;
}

this.notificationService.prompt(Severity.Info, searchForLanguagePacks,
[
{
label: searchMarketplace, run: () => {
this.viewletService.openViewlet(EXTENSIONS_VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => {
viewlet.search(`tag:lp-${platform.locale}`);
viewlet.focus();
});
}
},
{
label: dontShowAgain, run: () => {
dontShowSearchForLanguages.push(language);
this.storageService.store(dontShowSearchLanguagePacksAgainKey, StorageScope.GLOBAL, dontShowSearchForLanguages);
}
}
]);

}

private getLanguagePackExtension(language: string): TPromise<IGalleryExtension> {
Expand Down

0 comments on commit 43d48b1

Please sign in to comment.