Skip to content

Add Simplified Chinese (zh-cn) localization - #650

Open
Hengqian Ling (linghengqian) wants to merge 4 commits into
microsoft:mainfrom
linghengqian:feat/zh-cn-localization
Open

Hengqian Ling (linghengqian) wants to merge 4 commits into
microsoft:mainfrom
linghengqian:feat/zh-cn-localization

Conversation

@linghengqian

@linghengqian Hengqian Ling (linghengqian) commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

Fixes #648. Container Tools shipped no translations, so with a non-English display language everything the extension adds stayed in English. This adds Simplified Chinese (zh-cn) and the tooling that keeps translations in step with the code. Other languages can be added the same way, see docs/localization.md.

  • Add package.nls.zh-cn.json (388 strings) and l10n/bundle.l10n.zh-cn.json (584 strings), and set "l10n": "./l10n" in package.json.
  • Add scripts/l10n.mjs, built on @vscode/l10n-dev. pnpm --filter vscode-containers run l10n regenerates the English template l10n/bundle.l10n.json from the extension, the workspace packages it bundles (including vscode-docker-registries), and the dependencies that ship their own bundle. The @microsoft/vscode-azext-* libraries are in that last group: they are bundled into the extension, and VS Code looks up their vscode.l10n.t calls in the extension's bundle.
  • Run lint:l10n as part of lint. It fails when the template is out of date, or when a translation would break the UI: a lost {0} placeholder, a changed command: link or code span, or different line breaks or surrounding spaces. Missing or stale translations are only reported, because VS Code falls back to English.
  • Localize the strings that were still literals: five button and option labels, the walkthrough altTexts, displayName, description and the settings title, the default label of the containers.commands.* settings, and the Error messages. The filter prompts now use whole sentences per tree instead of splicing containers or images into one.
  • Localize the Compose language service. It runs in its own process, so the extension sends vscode.l10n.bundle in initializationOptions.l10nBundle and the server uses @vscode/l10n. Hover texts, code lenses and completion details are covered.
  • Document the process and the zh-cn terminology in docs/localization.md and CONTRIBUTING.md.

The English text is unchanged. Not covered: the Dockerfile language server (a third-party package with hard-coded English messages), the diagnostics of the Compose language service (they come from the yaml library), and the errors of vscode-container-client and vscode-processutils, which don't depend on vscode.

Validation

  • pnpm lint and pnpm build.
  • Extension tests: 234 passing, run as xvfb-run -a pnpm exec vscode-test --skip-extension-dependencies (the flag only matters on WSL, where bin/code waits for a prompt).
  • Compose language service tests: 155 passing on Node 22.18, including 4 new ones for the translations. They fail when the translations aren't passed on, or when a completion text is evaluated before they arrive.
  • pnpm --filter vscode-containers run package: the Marketplace manifest keeps the English displayName and description, the localization files are in the VSIX, and scripts/ is not.
  • lint:l10n also passes on Node 22.18, the version in .nvmrc.

Manual UI checks

Checked in an Extension Development Host (VS Code 1.145) with the Chinese (Simplified) Language Pack:

  • Command Palette titles, the Containers views and the Help and Feedback items are translated, and so are the descriptions in the Settings editor.
  • Default Settings (JSON) shows the translated default label of containers.commands.composeLogs.
  • The confirmation dialog of Prune System... is translated, including its Remove button (cancelled, nothing was pruned).
  • In a Compose file, the code lenses above services: and each service, and the hover text of keys such as image, are translated. That covers the language server process.
  • A string of @microsoft/vscode-azext-utils is translated: (Press 'Space' to select and 'Enter' to confirm), shown by Compose Up - Select Services.
  • With the display language set to English, the same Compose file shows the original English texts.

To check it yourself, install the language pack, run Configure Display Language, and start the Run Extension launch configuration.

Notes for reviewers

  • The terminology follows common Chinese Docker usage (镜像, 镜像仓库, 构建) rather than the Microsoft terms (映像, 注册表, 生成). The table is in docs/localization.md, so it is easy to change in one pass.
  • lint:l10n also fails when updating a @microsoft/vscode-azext-* library adds strings, until pnpm run l10n is run. It can be dropped without affecting the translations.
  • The Error messages are localized too, so they reach telemetry in the user's language. The reasons given to UserCancelledError are left alone, because they are telemetry values.
  • @vscode/l10n is a new runtime dependency of the Compose language server bundle (MIT, no dependencies of its own), so NOTICE.html needs regenerating the usual way. NOTICE.html and the changelog are not touched here.
  • @vscode/l10n-dev is a devDependency and adds 26 dev-only packages to the lockfile.

@linghengqian
Hengqian Ling (linghengqian) requested a review from a team as a code owner November 5, 2026 05:08
Copilot AI lite review requested due to automatic review settings November 5, 2026 05:08
Fixes microsoft#648

Add the zh-cn translations of the manifest (package.nls.zh-cn.json) and of
the runtime strings (l10n/bundle.l10n.zh-cn.json), and set "l10n" in
package.json so VS Code loads them.

scripts/l10n.mjs, built on @vscode/l10n-dev, regenerates the English
template l10n/bundle.l10n.json from the extension, the workspace packages
it bundles, and the dependencies that ship their own bundle. lint now also
runs `lint:l10n`, which fails when the template is out of date or when a
translation would break the UI (a lost placeholder, link, code span, line
break or surrounding space).

Localize the strings that were still literals: button labels, walkthrough
alt texts, displayName/description/settings title, the default labels of the
command template settings, Error messages, and the filter prompts. The
Compose language service runs in its own process, so the extension sends it
the translations in initializationOptions.l10nBundle and it uses
@vscode/l10n.

This comment was marked as resolved.

lint:l10n only compared {0}-style placeholders, so a translation could drop
the "$" of ${workspaceFolder} or change the name in ${command:pickProcess}
and still pass. These variables are in the descriptions of the debug attach
properties and users copy them into launch.json, so compare them as a part
of their own.

Also coalesce the placeholder match to an empty array, like the other
parts, instead of relying on new Set(null).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Inline translation feedback.

- Use a switch for the placeholder and title of the filter prompts, and
  regenerate the l10n template for the new string order.
- zh-cn: name `compose down` instead of translating "take down" as "stop",
  and translate "out of date" and "outdated" as "not the latest version"
  instead of "expired".
- Note in eslint.config.mjs when the local ignore of scripts/ can go.
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.

Add localization (i18n) support, starting with Simplified Chinese (zh-cn)

3 participants