Skip to content

Missing i18n for Submenu Labels under "Select" Menu #14995

@likesubject

Description

@likesubject

Problem Description

Submenu labels under the Select menu (e.g., "All", "Line", "Word") fail to display translated text when using non-English locales. This occurs because the menu labels in monaco-menu.ts were not properly internationalized

Original Code:

In @theia/monaco/src/browser/monaco-menu.ts, the buildMenuAction method did not apply localization handling to the label field. The original code directly used the raw label without passing it through the i18n system.

protected buildMenuAction(commandId: string, item: IMenuItem): MenuAction {
    const title = typeof item.command.title === 'string' ? item.command.title : item.command.title.value;
    const label = this.removeMnemonic(title);
    const order = item.order ? String(item.order) : '';
    return { commandId, order, label };
}

Modified Code:

protected buildMenuAction(commandId: string, item: IMenuItem): MenuAction {
    const title = typeof item.command.title === 'string' ? item.command.title : item.command.title.value;
    let label = this.removeMnemonic(title);
    const order = item.order ? String(item.order) : '';
    label = nls.localizeByDefault(label);
    return { commandId, order, label };
}

Environment:

  • Theia Version: 1.58.3
  • Operating System: Windows 10

Steps to Reproduce

  1. Set the IDE to a non-English locale (e.g., Chinese or French).
  2. Open the Select menu from the top menu bar.
  3. Observe untranslated submenu labels (e.g., "All", "Line").

Expected Behavior: Labels should display translated text according to the configured locale.
Actual Behavior: Labels show raw English text.

Proposed Fix

Added nls.localizeByDefault() to ensure labels are processed for internationalization. Below is the code change:

protected buildMenuAction(commandId: string, item: IMenuItem): MenuAction {
    const title = typeof item.command.title === 'string' ? item.command.title : item.command.title.value;
    let label = this.removeMnemonic(title);
    const order = item.order ? String(item.order) : '';
+    label = nls.localizeByDefault(label);
    return { commandId, order, label };
}

Metadata

Metadata

Assignees

Labels

bugbugs found in the applicationlocalizationissues related to localization/internalization/nlsmonacoissues related to monaco

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions