Unable to get localization working

I’m trying to add internationalization support to a theia-based app by following these instructions: Theia - Cloud and Desktop IDE Platform

To eliminate the possibility of faulty interaction with other modules or code in my theia-based app, I’ve applied the i18n relevant changes to a bare-bones backend theia extension generated using the theia yeoman extension generator.

As the source suggests, the app downloads the vscode-language-pack-fr

  "theiaPluginsDir": "plugins",
  "theiaPlugins": {
    "vscode-language-pack-fr": "https://open-vsx.org/api/MS-CEINTL/vscode-language-pack-fr/1.53.2/file/MS-CEINTL.vscode-language-pack-fr-1.53.2.vsix"
  }

Launching the app, however, and invoking the Configure Display Language command shows only the default en language pack:

The full source, which is tiny, is available here: https://deltopia.com/theia-i18n-ext.zip

Simply download, cd into the theia-i18n-ext, then yarn and yarn start:electron.

The CustomLocalizationContribution.registerLocalizations() doesn’t get called either, likely due to the same reason causing Theia to not pick up the French localization.

Hey @Yoli,

first off, your configured plugins aren’t downloaded automatically when you start the application. Instead, they are downloaded as a build step. You can use the theia-cli plugin downloader in a package.json script like "download:plugins": "theia download:plugins" and run that in the prepare script. See also this documentation page.

Additionally, it seems like you’re missing a crucial part of getting the backend contribution to work. You didn’t apply the bindings in your backend module:

bind(CustomLocalizationContribution).toSelf().inSingletonScope();
bind(LocalizationContribution).toService(CustomLocalizationContribution);

@msujew - many thanks for the prompt, spot-on reply!

Adding "@theia/vsx-registry": "latest" to my extension dependencies did result in vscode language extensions getting loaded indeed. The CustomLocalizationContribution binding was simply my omission when putting together the sample project to illustrate the problem.

With those things out of the way, localization is working beautifully in my sample project!

Adding "@theia/vsx-registry": "latest", to my actual extension dependencies however causes up the following build error:

browser-app: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
...

It appears that increasing node’s heap space (--max_old_space_size) would be the solution… what’s the correct way to do that in the Theia build workflow?

This is clearly a different problem, please let me know if I should create a new ticket/topic for it.

Adding "@theia/vsx-registry": "latest" to my extension dependencies did result in vscode language extensions getting loaded indeed.

Note that this does not load the vscode language extension by itself. It might be that you’re missing an explicit reference to the @theia/plugin-ext-vscode package which contains the vscode plugin support (and also the language pack support). It is indirectly referenced by the vsx-registry package, which is why it works now correctly.

what’s the correct way to do that in the Theia build workflow?

A theia build usually shouldn’t hit the JS heap limit. Are you building inside of a docker container? It might be that docker doesn’t allocate enough memory to the container. Theia needs somewhere in the range of 3GB of RAM to build.

Thank you @msujew.

Prior to posting this topic I had tried adding @theia/plugin-ext and @theia/plugin-ext-vscode as dependencies, taking clues from arduino-ide/package.json at main · arduino/arduino-ide · GitHub which resulted in the same heap limit error, so unconvinced that they were necessary I simply dropped them.

Short of Theia extensions like @theia/core, @theia/filesystem, @theia/preferences whose names make their purpose easy to guess, figuring out required dependencies, or the raison d’etre of @theia/ modules, has been mostly a trial and error affair. Is there a way to explore what the different Theia extensions do and when they are required dependencies?

A theia build usually shouldn’t hit the JS heap limit.

I was also surprised that our app is hitting the heap limit (when listing @theia/plugin-ext as a dependency) - it uses only a handful of theia’s extensions and the number of own files is not that large - slightly over a thousand at the moment.

Are you building inside of a docker container?

No container for now, plain Theia build with a couple Theia extensions (~1,200 files).

Happy to share additional information that may help you offer a suggestion how to solve/prevent the heap limit error.

To bring this to closure - the problem was due to webpack throwing an out of heap memory error, something it would do in several different scenarios, including certain types of circular references.