Skip to content

Allow language packs to override settings display labels - #324190

Open
boxi-wangji wants to merge 6 commits into
microsoft:mainfrom
boxi-wangji:upstream/settings-display-label-overrides
Open

Allow language packs to override settings display labels#324190
boxi-wangji wants to merge 6 commits into
microsoft:mainfrom
boxi-wangji:upstream/settings-display-label-overrides

Conversation

@boxi-wangji

@boxi-wangji boxi-wangji commented Jul 3, 2026

Copy link
Copy Markdown

Summary

  • Add optional module translation tables from language packs (
    ls.moduleTranslations.json)
  • Allow language packs to override settings UI category, title, and enum labels via settingDisplay.* keys
  • Core displays override strings as-is with no locale-specific parsing

Motivation

Setting descriptions are already localized, but the settings list derives short labels from setting keys. Language packs need a supported way to provide clearer display labels without patching VS Code core.

Language pack contract

  • settingDisplay.{configKey}: full setting label override
  • settingDisplayCategory.{categoryPath}: full category label override
  • settingDisplay.{configKey}.{enumValue}: full enum option label override

Test plan

  • Install a language pack that includes the settingsDisplayLabels module
  • Verify overridden settings show the language pack label/category
  • Verify settings without overrides are unchanged
  • Verify enum dropdowns use overrides when provided

Made with Cursor

Language packs can ship optional settingDisplay.* entries in a dedicated module. VS Code loads these module translations at startup and uses them to override settings list category, title, and enum labels without locale-specific logic in core.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings July 3, 2026 10:14
@vs-code-engineering

vs-code-engineering Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@deepak1556

Matched files:

  • src/vs/code/electron-browser/workbench/workbench.ts

@rzhao271

Matched files:

  • src/vs/workbench/contrib/preferences/browser/media/settingsEditor2.css
  • src/vs/workbench/contrib/preferences/browser/settingsDisplayLabels.ts
  • src/vs/workbench/contrib/preferences/browser/settingsTree.ts
  • src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts
  • src/vs/workbench/contrib/preferences/test/browser/settingsTreeModels.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a supported mechanism for language packs to override the settings UI display labels (category, title, and enum option labels) without patching VS Code core. It threads a new per-module translation table (nls.moduleTranslations.json) out of the language pack cache, propagates it as a _VSCODE_NLS_MODULE_TRANSLATIONS global across the main process and renderer(s), and consults it in the settings tree when computing display labels. This fits into the existing NLS/language-pack infrastructure (src/vs/nls.ts, src/vs/base/node/nls.ts, sandbox config) and the preferences editor.

Changes:

  • Introduce a language-pack-provided module translation table and plumb it from cache generation → bootstrap → main → renderer globals.
  • Add settingsDisplayLabels.ts override helpers and wire them into settingsTreeModels/settingsTree for category, title, and enum labels.
  • Adjust settings editor CSS to support wrapped/pre-line labels.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/nls.ts Adds getNLSModuleTranslations/getNLSModuleTranslationsMap accessors and moduleTranslationsFile config field.
src/typings/vscode-globals-nls.d.ts Declares the new _VSCODE_NLS_MODULE_TRANSLATIONS global.
src/vs/base/node/nls.ts Generates/reuses nls.moduleTranslations.json and extracts only the settings-display-labels module.
src/bootstrap-esm.ts Loads module translations from the language pack file into the global.
src/vs/base/parts/sandbox/common/sandboxTypes.ts Adds optional moduleTranslations to sandbox NLS config.
src/vs/platform/windows/electron-main/windowsMainService.ts Passes module translations map into the window config.
src/vs/code/electron-browser/workbench/workbench.ts Initializes the renderer global from config.
src/vs/sessions/electron-browser/sessions.ts Same renderer initialization for the Agents window.
src/vs/workbench/contrib/preferences/browser/settingsDisplayLabels.ts New override lookup helpers (category/label/enum).
src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts Consults overrides before fallback labels; renames initLabelsinitFallbackLabels.
src/vs/workbench/contrib/preferences/browser/settingsTree.ts Applies enum label overrides in the dropdown renderer.
src/vs/workbench/contrib/preferences/browser/media/settingsEditor2.css Allows pre-line labels and clears the description below floated labels.

Comment thread src/vs/base/node/nls.ts
return defaultNLSConfiguration(userLocale, osLocale, nlsMetadataPath);
}

const SETTING_DISPLAY_LABELS_MODULE = 'vs/workbench/contrib/preferences/browser/settingsDisplayLabels';
Comment on lines +23 to +37
export function getSettingDisplayCategoryOverride(settingKey: string): string | undefined {
if (!settingKey.includes('.')) {
return undefined;
}

const categoryPath = settingKey.substring(0, settingKey.lastIndexOf('.'));
for (const path of [categoryPath, categoryPath.split('.')[0]]) {
const value = readOverride(`settingDisplayCategory.${path}`);
if (value) {
return value;
}
}

return undefined;
}
boxi-wangji and others added 2 commits July 3, 2026 18:36
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants