Skip to content

Restoring current language might fail at start-up  #11471

@AlbyIanna

Description

@AlbyIanna

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:

let locale = req.params.locale;
locale = this.localizationProvider.getAvailableLanguages().some(e => e.languageId === locale) ? locale : 'en';

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)
if (all || localization.languagePack) {

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: arduino/arduino-ide#1219

Additional Information

Passing true to getAvailableLanguages fixes the issue for me.

  • Operating System: MacOS
  • Theia Version: 1.25.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    localizationissues related to localization/internalization/nls

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions