Skip to content

Set the current language on the localization provider #957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ export class SettingsService {
// after saving all the settings, if we need to change the language we need to perform a reload
// Only reload if the language differs from the current locale. `nls.locale === undefined` signals english as well
if (
currentLanguage !== nls.locale &&
!(currentLanguage === 'en' && nls.locale === undefined)
currentLanguage !== (await this.localizationProvider.getCurrentLanguage())
) {
await this.localizationProvider.setCurrentLanguage(currentLanguage);
if (currentLanguage === 'en') {
window.localStorage.removeItem(nls.localeId);
} else {
Comment on lines 284 to 286
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kittaakos do you think it's necessary to save the locale id to the local storage like this in order for the localization to work?

I thought that setting the current language to the localization provider was enough, so I've tried removing this code, but then the localization didn't work correctly, therefore it appears it is not enough.

Expand Down
4 changes: 0 additions & 4 deletions arduino-ide-extension/src/node/arduino-daemon-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Event, Emitter } from '@theia/core/lib/common/event';
import { environment } from '@theia/application-package/lib/environment';
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
import { LocalizationProvider } from '@theia/core/lib/node/i18n/localization-provider';
import { ArduinoDaemon, NotificationServiceServer } from '../common/protocol';
import { DaemonLog } from './daemon-log';
import { CLI_CONFIG } from './cli-config';
Expand All @@ -32,9 +31,6 @@ export class ArduinoDaemonImpl
@inject(NotificationServiceServer)
protected readonly notificationService: NotificationServiceServer;

@inject(LocalizationProvider)
protected readonly localizationProvider: LocalizationProvider;

protected readonly toDispose = new DisposableCollection();
protected readonly onDaemonStartedEmitter = new Emitter<void>();
protected readonly onDaemonStoppedEmitter = new Emitter<void>();
Expand Down