Can I override core translations?

In my Theia-based IDE, I am storing additional information in the workspace file so that it functions as a project file. Consequently, I would like the UI to refer as it as such, instead of “Workspace”.

Therefore, I created a custom LocalizationContribution as in the following:

export class CustomLocalizationContribution implements LocalizationContribution {
  async registerLocalizations(registry: LocalizationRegistry): Promise<void> {
    registry.registerLocalizationFromRequire('en', require('../../../i18n/nls.en.json'));
    // ...

With the nls.en.json file overriding a respective translation key:

    "theia": {
        "workspace": {
            "openRecentWorkspace": "Open Recent Project..."

However, in the UI, the translation appears as those of a language pack would:

Is there any way to override a core translation without the “original translation” being shown below?

I mean, I could probably rebind TheiaLocalizationContribution to achieve this. But is there an easier, less hacky way?

Hi @cradke,

so in the case of commands, you can always simply reassign the label:

// root level of the file, executed during loading
WorkspaceCommands.OPEN_RECENT_WORKSPACE.label = 'Open Recent Project...';

For everything else, your approach should work well.

Thanks for the quick reply, @msujew. This solution looks great! Which file should I do the reassigning in, though? I removed the override from nls.en.json and added the suggested override to the root level of my frontend module, but the result was the same as before.

Nevermind, I got things to work as intended by also reassigning the originalLabel. So now I am doing the following:

WorkspaceCommands.OPEN_RECENT_WORKSPACE.label = 'Open Recent Project...' 
    && nls.localize('vuengine/project/commands/openRecentProject', 'Open Recent Project...');
WorkspaceCommands.OPEN_RECENT_WORKSPACE.originalLabel = 'Open Recent Project...';

Thank you for your help! :slight_smile: