theia icon indicating copy to clipboard operation
theia copied to clipboard

Restoring current language might fail at start-up

Open AlbyIanna opened this issue 2 years ago • 0 comments

Bug Description:

It might happen that, when setting a language different from en, the language is not restored when quitting and reopening the IDE.

Doing some research, I noticed the root of the problem is here: https://github.com/eclipse-theia/theia/blob/f4327c2f0c0f47f960a302590a51698879357841/packages/core/src/node/i18n/localization-backend-contribution.ts#L38-L39 req.params.locale is always restored correctly, but this.localizationProvider.getAvailableLanguages() doesn't return all the available languages. This happens because getAvailableLanguages() returns all the registered localizations with languagePack set to true (unless we call getAvailableLanguages(true), in that case, it would always return all the languages) https://github.com/eclipse-theia/theia/blob/f4327c2f0c0f47f960a302590a51698879357841/packages/core/src/node/i18n/localization-provider.ts#L50

The weird thing is that this happens also with some languages registered with a language pack (so they'll eventually have languagePack set to true). I say some languages because some other work as expected. I strongly believe this is happening because of a race condition happening because getAvailableLanguages is called before the language packs are finished loading.

Steps to Reproduce:

You can use this bug in the Arduino IDE as a reference to reproduce this bug: https://github.com/arduino/arduino-ide/issues/1219

Additional Information

Passing true to getAvailableLanguages fixes the issue for me.

  • Operating System: MacOS
  • Theia Version: 1.25.0

AlbyIanna avatar Jul 27 '22 17:07 AlbyIanna