Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/workbench/contrib/extensions/browser/extensionsActions.ts')
-rw-r--r--src/vs/workbench/contrib/extensions/browser/extensionsActions.ts50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
index 23ddb1a771c..d2247bf2519 100644
--- a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
+++ b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
@@ -67,6 +67,7 @@ import { flatten } from 'vs/base/common/arrays';
import { fromNow } from 'vs/base/common/date';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { ILanguagePackService } from 'vs/platform/languagePacks/common/languagePacks';
+import { ILocaleService } from 'vs/workbench/contrib/localization/common/locale';
export class PromptExtensionInstallFailureAction extends Action {
@@ -981,6 +982,8 @@ export class DropDownMenuActionViewItem extends ActionViewItem {
async function getContextMenuActionsGroups(extension: IExtension | undefined | null, contextKeyService: IContextKeyService, instantiationService: IInstantiationService): Promise<[string, Array<MenuItemAction | SubmenuItemAction>][]> {
return instantiationService.invokeFunction(async accessor => {
+ const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
+ const languagePackService = accessor.get(ILanguagePackService);
const menuService = accessor.get(IMenuService);
const extensionRecommendationsService = accessor.get(IExtensionRecommendationsService);
const extensionIgnoredRecommendationsService = accessor.get(IExtensionIgnoredRecommendationsService);
@@ -1006,6 +1009,9 @@ async function getContextMenuActionsGroups(extension: IExtension | undefined | n
cksOverlay.push(['extensionHasColorThemes', colorThemes.some(theme => isThemeFromExtension(theme, extension))]);
cksOverlay.push(['extensionHasFileIconThemes', fileIconThemes.some(theme => isThemeFromExtension(theme, extension))]);
cksOverlay.push(['extensionHasProductIconThemes', productIconThemes.some(theme => isThemeFromExtension(theme, extension))]);
+
+ cksOverlay.push(['canSetLanguage', extensionsWorkbenchService.canSetLanguage(extension)]);
+ cksOverlay.push(['isActiveLanguagePackExtension', extension.gallery && language === languagePackService.getLocale(extension.gallery)]);
}
const menu = menuService.createMenu(MenuId.ExtensionContext, contextKeyService.createOverlay(cksOverlay));
@@ -1791,10 +1797,10 @@ export class SetProductIconThemeAction extends ExtensionAction {
export class SetLanguageAction extends ExtensionAction {
- static readonly ID = 'workbench.extensions.action.setLanguageTheme';
- static readonly TITLE = { value: localize('workbench.extensions.action.setLanguageTheme', "Set Display Language"), original: 'Set Display Language' };
+ static readonly ID = 'workbench.extensions.action.setDisplayLanguage';
+ static readonly TITLE = { value: localize('workbench.extensions.action.setDisplayLanguage', "Set Display Language"), original: 'Set Display Language' };
- private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} theme`;
+ private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} language`;
private static readonly DisabledClass = `${SetLanguageAction.EnabledClass} disabled`;
constructor(
@@ -1826,6 +1832,44 @@ export class SetLanguageAction extends ExtensionAction {
}
}
+export class ClearLanguageAction extends ExtensionAction {
+
+ static readonly ID = 'workbench.extensions.action.clearLanguage';
+ static readonly TITLE = { value: localize('workbench.extensions.action.clearLanguage', "Clear Display Language"), original: 'Clear Display Language' };
+
+ private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} language`;
+ private static readonly DisabledClass = `${ClearLanguageAction.EnabledClass} disabled`;
+
+ constructor(
+ @IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
+ @ILanguagePackService private readonly languagePackService: ILanguagePackService,
+ @ILocaleService private readonly localeService: ILocaleService,
+ ) {
+ super(ClearLanguageAction.ID, ClearLanguageAction.TITLE.value, ClearLanguageAction.DisabledClass, false);
+ this.update();
+ }
+
+ update(): void {
+ this.enabled = false;
+ this.class = ClearLanguageAction.DisabledClass;
+ if (!this.extension) {
+ return;
+ }
+ if (!this.extensionsWorkbenchService.canSetLanguage(this.extension)) {
+ return;
+ }
+ if (this.extension.gallery && language !== this.languagePackService.getLocale(this.extension.gallery)) {
+ return;
+ }
+ this.enabled = true;
+ this.class = ClearLanguageAction.EnabledClass;
+ }
+
+ override async run(): Promise<any> {
+ return this.extension && this.localeService.clearLocalePreference();
+ }
+}
+
export class ShowRecommendedExtensionAction extends Action {
static readonly ID = 'workbench.extensions.action.showRecommendedExtension';