Skip to content

Commit

Permalink
Use notification instead for progress and ensure Language Pack gets s…
Browse files Browse the repository at this point in the history
…ynced (microsoft#151544)
  • Loading branch information
TylerLeonhardt authored Jun 8, 2022
1 parent 601da40 commit 06c4b0a
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
import { IExtensionsViewPaneContainer, VIEWLET_ID as EXTENSIONS_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions';
import { ViewContainerLocation } from 'vs/workbench/common/views';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { localize } from 'vs/nls';

export class NativeLocaleService implements ILocaleService {
_serviceBrand: undefined;
Expand All @@ -24,6 +26,7 @@ export class NativeLocaleService implements ILocaleService {
@ILanguagePackService private readonly languagePackService: ILanguagePackService,
@IPaneCompositePartService private readonly paneCompositePartService: IPaneCompositePartService,
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
@IProgressService private readonly progressService: IProgressService
) { }

private async writeLocaleValue(locale: string | undefined): Promise<void> {
Expand All @@ -41,16 +44,26 @@ export class NativeLocaleService implements ILocaleService {
// Only Desktop has the concept of installing language packs so we only do this for Desktop
// and only if the language pack is not installed
if (!installedLanguages.some(installedLanguage => installedLanguage.id === languagePackItem.id)) {
// Show the view so the user can see the language pack to be installed
let viewlet = await this.paneCompositePartService.openPaneComposite(EXTENSIONS_VIEWLET_ID, ViewContainerLocation.Sidebar);
(viewlet?.getViewPaneContainer() as IExtensionsViewPaneContainer).search(`@id:${languagePackItem.extensionId}`);

// Only actually install a language pack from Microsoft
if (languagePackItem.galleryExtension?.publisher.toLowerCase() !== 'ms-ceintl') {
// Show the view so the user can see the language pack that they should install
// as of now, there are no 3rd party language packs available on the Marketplace.
let viewlet = await this.paneCompositePartService.openPaneComposite(EXTENSIONS_VIEWLET_ID, ViewContainerLocation.Sidebar);
(viewlet?.getViewPaneContainer() as IExtensionsViewPaneContainer).search(`@id:${languagePackItem.extensionId}`);
return false;
}

await this.extensionManagementService.installFromGallery(languagePackItem.galleryExtension);
await this.progressService.withProgress(
{
location: ProgressLocation.Notification,
title: localize('installing', "Installing {0} language support...", languagePackItem.label),
},
progress => this.extensionManagementService.installFromGallery(languagePackItem.galleryExtension!, {
// Setting this to false is how you get the extension to be synced with Settings Sync (if enabled).
isMachineScoped: false,
})
);
}

await this.writeLocaleValue(locale);
Expand Down

0 comments on commit 06c4b0a

Please sign in to comment.