Skip to content

Commit

Permalink
feat: defer initializing i18n at backend startup
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
  • Loading branch information
Akos Kitta committed Sep 12, 2023
1 parent 2071ab8 commit b788005
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
10 changes: 5 additions & 5 deletions arduino-ide-extension/src/node/arduino-ide-backend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ import WebSocketProviderImpl from './web-socket/web-socket-provider-impl';
import { WebSocketProvider } from './web-socket/web-socket-provider';
import { ClangFormatter } from './clang-formatter';
import { FormatterPath } from '../common/protocol/formatter';
import { HostedPluginLocalizationService } from './theia/plugin-ext/hosted-plugin-localization-service';
import { HostedPluginLocalizationService as TheiaHostedPluginLocalizationService } from '@theia/plugin-ext/lib/hosted/node/hosted-plugin-localization-service';
import { LocalizationBackendContribution } from '@theia/core/lib/node/i18n/localization-backend-contribution';
import { PluginLocalizationBackendContribution } from './theia/plugin-ext/plugin-localization-backend-contribution';
import { SurveyNotificationServiceImpl } from './survey-service-impl';
import {
SurveyNotificationService,
Expand Down Expand Up @@ -374,9 +374,9 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(BackendApplicationContribution).toService(PlotterBackendContribution);
bind(ArduinoLocalizationContribution).toSelf().inSingletonScope();
bind(LocalizationContribution).toService(ArduinoLocalizationContribution);
bind(HostedPluginLocalizationService).toSelf().inSingletonScope();
rebind(TheiaHostedPluginLocalizationService).toService(
HostedPluginLocalizationService
bind(PluginLocalizationBackendContribution).toSelf().inSingletonScope();
rebind(LocalizationBackendContribution).toService(
PluginLocalizationBackendContribution
);

// Survey notification bindings
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { injectable, postConstruct } from '@theia/core/shared/inversify';
import { PluginLocalizationBackendContribution as TheiaPluginLocalizationBackendContribution } from '@theia/plugin-ext/lib/main/node/plugin-localization-backend-contribution';

@injectable()
export class PluginLocalizationBackendContribution extends TheiaPluginLocalizationBackendContribution {
@postConstruct()
protected init(): void {
this.pluginDeployer.onDidDeploy(() => {
this.pluginsDeployed.resolve();
});
}

override async initialize(): Promise<void> {
// Unlike Theia, IDE2 does not await here.
// Otherwise the backend app startup is blocked until all translations are read.
// https://github.com/eclipse-theia/theia/blob/cb426569d1d5fe42567f5ec5d35b3c77a92f3295/packages/core/src/node/i18n/localization-backend-contribution.ts#L36-L37
this.localizationRegistry
.initialize()
.then(() => this.initialized.resolve());
}

override async waitForInitialization(): Promise<void> {
await Promise.all([this.initialized.promise, this.pluginsDeployed.promise]);
}
}

0 comments on commit b788005

Please sign in to comment.