forked from openkylin/kylin-code
文件菜单下,添加选择显示语言的子菜单.
This commit is contained in:
parent
bc3d7f2d07
commit
184984c9cc
|
@ -6540,7 +6540,11 @@
|
|||
"vscode.extension.contributes.localizations.translations": "与语言关联的翻译的列表。",
|
||||
"vscode.extension.contributes.localizations.translations.id": "使用此翻译的 VS Code 或扩展的 ID。VS Code 的 ID 总为 \"vscode\",扩展的 ID 的格式应为 \"publisherId.extensionName\"。",
|
||||
"vscode.extension.contributes.localizations.translations.id.pattern": "翻译 VS Code 或者扩展,ID 分别应为 \"vscode\" 或格式为 \"publisherId.extensionName\"。",
|
||||
"vscode.extension.contributes.localizations.translations.path": "包含语言翻译的文件的相对路径。"
|
||||
"vscode.extension.contributes.localizations.translations.path": "包含语言翻译的文件的相对路径。",
|
||||
"relaunchDisplayLanguageDetail": "按下重启按钮来重新启动 {0} 并更改显示语言。",
|
||||
"relaunchDisplayLanguageMessage": "要使显示语言的更改生效, 需要重新启动。",
|
||||
"cancel": "取消",
|
||||
"miSelectLanguage": "选择显示语言"
|
||||
},
|
||||
"vs/workbench/contrib/localization/electron-sandbox/minimalTranslations": {
|
||||
"installAndRestart": "安装并重启",
|
||||
|
|
|
@ -91,6 +91,9 @@ export class MenuId {
|
|||
static readonly MenubarTerminalMenu = new MenuId('MenubarTerminalMenu');
|
||||
static readonly MenubarViewMenu = new MenuId('MenubarViewMenu');
|
||||
static readonly MenubarHomeMenu = new MenuId('MenubarHomeMenu');
|
||||
//kylin ide add selecet disaplay language menu start{
|
||||
static readonly MenubarSelectLanguageMenu = new MenuId('MenubarSelectLanguageMenu');
|
||||
//kylin ide add selecet disaplay language menu start}
|
||||
static readonly OpenEditorsContext = new MenuId('OpenEditorsContext');
|
||||
static readonly ProblemsPanelContext = new MenuId('ProblemsPanelContext');
|
||||
static readonly SCMChangeContext = new MenuId('SCMChangeContext');
|
||||
|
|
|
@ -23,8 +23,14 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
|||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
|
||||
import { ViewContainerLocation } from 'vs/workbench/common/views';
|
||||
import { registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { Action2, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { ClearDisplayLanguageAction, ConfigureDisplayLanguageAction } from 'vs/workbench/contrib/localization/browser/localizationsActions';
|
||||
import { IsMacNativeContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { ILanguagePackService } from 'vs/platform/languagePacks/common/languagePacks';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { ILocaleService } from 'vs/workbench/services/localization/common/locale';
|
||||
|
||||
// Register action to configure locale and related settings
|
||||
registerAction2(ConfigureDisplayLanguageAction);
|
||||
|
@ -43,13 +49,58 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
|
|||
@IExtensionGalleryService private readonly galleryService: IExtensionGalleryService,
|
||||
@IPaneCompositePartService private readonly paneCompositeService: IPaneCompositePartService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@ILanguagePackService private readonly languagePackService: ILanguagePackService
|
||||
) {
|
||||
super();
|
||||
|
||||
if (!platform.isWeb) {
|
||||
this.registerSubMenu(this.languagePackService);
|
||||
}
|
||||
this.checkAndInstall();
|
||||
this._register(this.extensionManagementService.onDidInstallExtensions(e => this.onDidInstallExtensions(e)));
|
||||
}
|
||||
|
||||
private async registerSubMenu(languagePackService: ILanguagePackService) {
|
||||
const installedLanguages = await languagePackService.getInstalledLanguages();
|
||||
if (installedLanguages.length) {
|
||||
installedLanguages.map((item, index) => {
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: item.id!,
|
||||
title: item.label,
|
||||
menu: {
|
||||
id: MenuId.MenubarSelectLanguageMenu,
|
||||
order: index
|
||||
}
|
||||
});
|
||||
}
|
||||
async run(accessor: ServicesAccessor): Promise<void> {
|
||||
const dialogService = accessor.get(IDialogService);
|
||||
const hostService = accessor.get(IHostService);
|
||||
const productService = accessor.get(IProductService);
|
||||
const localeService: ILocaleService = accessor.get(ILocaleService);
|
||||
|
||||
if (await localeService.setLocale(item.id)) {
|
||||
const restartDialog = await dialogService.confirm({
|
||||
type: 'info',
|
||||
message: localize('relaunchDisplayLanguageMessage', "A restart is required for the change in display language to take effect."),
|
||||
detail: localize('relaunchDisplayLanguageDetail', "Press the restart button to restart {0} and change the display language.", productService.nameLong),
|
||||
primaryButton: localize('restart', "Restart"),
|
||||
secondaryButton: localize('cancel', "Cancel")
|
||||
});
|
||||
|
||||
if (restartDialog.confirmed) {
|
||||
hostService.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private onDidInstallExtensions(results: readonly InstallExtensionResult[]): void {
|
||||
for (const e of results) {
|
||||
if (e.local && e.operation === InstallOperation.Install && e.local.manifest.contributes && e.local.manifest.contributes.localizations && e.local.manifest.contributes.localizations.length) {
|
||||
|
@ -267,3 +318,15 @@ ExtensionsRegistry.registerExtensionPoint({
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!platform.isWeb) {
|
||||
//选择语言菜单
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
title: localize({ key: 'miSelectLanguage', comment: ['&& denotes a mnemonic'] }, "&&Display Language"),
|
||||
submenu: MenuId.MenubarSelectLanguageMenu,
|
||||
group: '5_autosave',
|
||||
order: 4,
|
||||
// on macOS native the preferences menu is separate under the application menu
|
||||
when: IsMacNativeContext.toNegated()
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue