Skip to content

Migrate localization to @vscode/l10n with request-scoped locale compatibility - #322

Draft
Matt Masson (mattmasson) wants to merge 6 commits into
masterfrom
dev/localization-with-vscode-l10n
Draft

Matt Masson (mattmasson) wants to merge 6 commits into
masterfrom
dev/localization-with-vscode-l10n

Conversation

@mattmasson

@mattmasson Matt Masson (mattmasson) commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Migrate parser and language-service messages to standard English-message-keyed bundle.l10n[.<locale>].json resources and use @vscode/l10n for named-placeholder formatting.
  • Preserve per-request locales, exact case-insensitive locale selection, English fallback, named locale exports, custom templates, public template interfaces/builders, and JavaScript/TypeScript module entry points.
  • Remove the complete obsolete localization resource mechanism from both packages: locale LCX handback trees, legacy manifests, English template JSON catalogs, duplicate generated locale JSON, and their plumbing. Bundles are the only localization resource files.
  • Preserve all message texts and public template fields through code-defined English bundle-key lookups in the existing exported templates.ts API modules. No second translation catalog or new framework is introduced.
  • The formatter inherits parser localization and has no messages or l10n dependency of its own. Its README documents locale forwarding and unchanged parser errors; its Unreleased changelog attributes the effect to the parser.

Approved runtime/API compatibility

@vscode/l10n 0.0.18 exposes singleton config() and t() functions, not a per-locale translator factory. The user approved a small adapter to preserve the per-request locale contract.

The adapter selects the locale-bound bundle first and calls l10n.t for interpolation. It never calls l10n.config or mutates host-global locale state. Package-name comments namespace calls so ordinary host bundles cannot translate selected text again; hosts must not deliberately define matching <selected message>/@microsoft/powerquery-parser or <selected message>/@microsoft/powerquery-language-services keys. No VS Code host, isolated module loading, or platform-specific context mechanism is required.

All repeated placeholders are replaced, replacement text (including dollar patterns and braces) stays literal, and unmatched placeholders remain visible. The exported general-purpose StringUtils.assertGetFormatted API is unchanged. Dynamic messages are maintained in bundles; extracting the adapter alone does not reconstruct them.

Complete obsolete-resource cleanup

The user explicitly approved removing unused legacy template resources rather than maintaining hypothetical direct JSON deep-import compatibility.

  • Removed both localization/loc/<locale>/templates handback trees: 82 LCX files.
  • Removed both obsolete LocProject.json manifests and both English template JSON catalogs.
  • The earlier 82 duplicate generated locale JSON outputs are no longer generated or shipped. Builds also remove stale loc, templates, and manifest resource paths from output.
  • Source, clean-build output, and tarballs contain only the 84 l10n bundles as localization resources. Packaging rejects obsolete resource files. Removed JSON resource deep imports are intentional; use bundle JSON or template APIs instead.
  • The useful exported templates.ts modules remain. Their minimal typed ID-to-bundle-key lookups derive English messages and metadata from the English bundle, preserving stable public IDs, field shapes, English fallback, and metadata aliases without separate resource catalogs.

Before deletion, all 4,018 active legacy message translations were confirmed present in bundles, including LCX-escaped closing brackets. The 41 unique translated developer-context comments were retained in the matching bundles using the supported { message, comment } object format. No message text changed during this cleanup.

An exact before/after snapshot verified all 8,568 public locale message/metadata values and field shapes across both packages. All 4,284 bundle message values are unchanged by the resource cleanup. Obsolete imports, copy/generation machinery, legacy synchronization assertions, documentation references, and resource allowlists are updated or removed. No translation/publishing pipeline or live settings were changed; this removes only the replaced source-resource mechanism.

Translation coverage

The initial migration carried forward existing message translations except four malformed-placeholder repairs: Galician unknown-identifier suggestions, Portuguese (Portugal) named missing-argument and unnamed type-mismatch diagnostics, and Serbian (Cyrillic) argument-count diagnostics.

The subsequent audit completed 190 message values across 41 locales: 161 documentation headings and 29 unknown-name diagnostics restored from existing translations. Type is intentionally unchanged where it is also correct native terminology in Danish, Norwegian Bokmål, and Dutch. German quote and Portuguese escape defects were corrected during restoration.

English source comments, keys, placeholders, code snippets and API names remain intact. English-identical parser values such as CancellationError, InvariantError, null, minus, and text are intentional technical/native terms. No unresolved English-prose candidates were found by the contextual audit; independent native-speaker certification was not performed.

Upstream and release scope

Merged origin/master 60cb007 via d84598d, including #320 and #321. Root-owned shared tooling and runtime ranges are preserved, along with both localization dependencies. Formatter docs clarification is aa3a287; complete obsolete-resource cleanup is 4b43ae1. No extra dependency modernization or formatter runtime changes are introduced. The PR remains a draft and has not been merged.

Verification

  • npm run clean and dependency-ordered npm run build — passed; no legacy localization resource directories, manifests or catalogs remain in output.
  • npm run lint and npm test — all package, parser-resource and release-helper suites passed; the existing parser skip remains.
  • Exact public-template snapshot, legacy-message audit, unchanged message-value checks and retained context-comment checks — passed.
  • Resource tests check bundle-only source/output inventory, coverage, English keys, comments, placeholders and intentional identical-native-word handling; tar checks reject obsolete assets.
  • npm run validate:release — passed again at the committed cleanup revision. All three actual tarballs install outside the workspaces; consumer type-checking and runtime checks cover template API imports, string/message-comment bundle forms, translated diagnostics/documentation, concurrent locales, parser/formatter propagation, literal substitutions, English fallback and unchanged host l10n configuration.

Matt Masson and others added 6 commits November 5, 2026 20:31
Preserve request-scoped locale selection and published template contracts through a compatibility adapter. Use l10n for named substitutions without configuring its global singleton, and validate bundle assets and external package consumers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…th-vscode-l10n

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	package-lock.json
#	packages/powerquery-language-services/package.json
Translate parameter documentation labels across supported locales and restore missing unknown-name diagnostics from existing translated resources. Preserve intentional technical tokens and native words, synchronize legacy target repairs, and validate locale/resource parity and packed consumers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep l10n bundles as the translation source and preserve the public TypeScript locale APIs using their required English key catalogs. Remove legacy JSON generation/import checks, clean stale build assets, and reject per-locale template JSON in tarballs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Document locale forwarding and unchanged parser errors in the existing settings guidance. Attribute the shared release's localization change to the parser without implying formatter-specific runtime code or dependencies.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep bundles as the only localization resources, deriving stable template IDs and metadata through code-defined bundle-key lookups. Preserve all public locale values and unique legacy context comments, remove unused LCX/manifests/JSON catalogs, and validate source/output/tarball cleanup and consumers.

Co-authored-by: Copilot App <223556219+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.

1 participant