-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
bugbugs found in the applicationbugs found in the applicationlocalizationissues related to localization/internalization/nlsissues related to localization/internalization/nlsmonacoissues related to monacoissues related to monaco
Description
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
- Set the IDE to a non-English locale (e.g., Chinese or French).
- Open the Select menu from the top menu bar.
- 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 applicationbugs found in the applicationlocalizationissues related to localization/internalization/nlsissues related to localization/internalization/nlsmonacoissues related to monacoissues related to monaco