- Inclusive by default: all user‑facing text is localizable.
- Privacy‑first and offline: no network calls; translations ship with the extension.
- Predictable keys: two namespaces —
manifest.*forpackage.jsonUI andruntime.*for in‑code strings. - Safe fallbacks: English is bundled and used when a key or locale is missing.
- Translator‑friendly: consistent placeholders, small focused sentences, and a source
language.jsoncatalogue.
Non‑goals:
- Remote translation fetching or telemetry.
- Complex runtime pluralization logic. We use positional
{0}placeholders withvscode-nls.
src/i18n/
package.nls.de.json
package.nls.es.json
package.nls.fr.json
package.nls.id.json
package.nls.it.json
package.nls.ja.json
package.nls.ko.json
package.nls.pt-br.json
package.nls.ru.json
package.nls.uk.json
package.nls.vi.json
package.nls.zh-cn.json
language.json # source catalogue of English strings (see API below)
package.nls.json # base English manifest/runtime keys
package.json # wired to l10n; copies localized files on publish
Notes:
- During packaging,
src/i18n/package.nls*.jsonfiles are copied to the extension root by thevscode:prepublishscript so VS Code can discover them. - VS Code discovers manifest translations based on the
l10nfield inpackage.jsonand thepackage.nls*.jsonnaming convention.
Supported locales out of the box:
| Locale | File |
|---|---|
| German | package.nls.de.json |
| Spanish | package.nls.es.json |
| French | package.nls.fr.json |
| Indonesian | package.nls.id.json |
| Italian | package.nls.it.json |
| Japanese | package.nls.ja.json |
| Korean | package.nls.ko.json |
| Portuguese (Brazil) | package.nls.pt-br.json |
| Russian | package.nls.ru.json |
| Ukrainian | package.nls.uk.json |
| Vietnamese | package.nls.vi.json |
| Chinese (Simplified) | package.nls.zh-cn.json |
Used by package.json contributions (commands, configuration, menus, capabilities):
{
"displayName": "%manifest.ext.name%",
"description": "%manifest.ext.desc%",
"contributes": {
"commands": [
{
"command": "string-le.extractStrings",
"title": "%manifest.command.extract.title%",
"category": "%manifest.command.category%"
}
]
}
}Translations map 1:1 in package.nls.json and per‑locale files:
{
"manifest.ext.name": "String-LE",
"manifest.command.category": "String-LE",
"manifest.command.extract.title": "String-LE: Extract"
}Used in TypeScript via vscode-nls with MessageFormat.file:
import * as nls from 'vscode-nls'
const localize = nls.config({ messageFormat: nls.MessageFormat.file })()
// Example usages
const tooltip = localize('runtime.status.tooltip', 'Run String-LE: Extract')
const warn = localize('runtime.message.warn.large-file', 'Large file detected ({0} bytes). Extraction may take longer.', fileSize)Placeholders are positional: {0}, {1}, … and must be preserved by translators.
Purpose: a translator‑friendly catalogue of canonical English phrases used across both manifest and runtime. This file is not parsed at runtime by the extension; it exists to help maintain coverage and drive translation workflows and checks.
Format:
- Newline‑delimited plain text, one phrase per line.
- No JSON object/array wrapping;
.jsonextension chosen for editor syntax and tooling convenience. - Lines should be exact English source messages, including punctuation and placeholder tokens like
{0}.
Contract:
- Duplicates are allowed if the same phrase appears in multiple contexts.
- Do not translate this file; create/update per‑locale
package.nls.{locale}.jsoninstead. - When adding/removing user‑facing strings in code or
package.json, update:package.nls.jsonwith the new key/value (English)src/i18n/language.jsonwith the raw English phrase- Any existing locale files you can confidently translate; others will gracefully fall back to English
Validation (recommended):
- CI or local scripts can diff
language.jsonagainst the values inpackage.nls.jsonto detect missing coverage.
Example excerpt:
String-LE: Extract
Large output ({0} lines). Proceed?
Run String-LE: Extract
Copied to clipboard
Guidelines:
- Keep sentences short and unambiguous.
- Use sentence case and consistent terminology.
- Prefer verbs for actions (Extract, Copy, Open) and descriptive titles for prompts.
- Always pass an English default to
localize(key, default, ...args); this is used as the fallback string. - Use positional placeholders
{0},{1}and provide values in the same order in code. - Avoid embedding quotes unless necessary; prefer readable punctuation and Unicode arrows where already used.
- Do not hardcode user‑visible text in code; route through
localize(...).
Anti‑patterns:
- Concatenating translated fragments at runtime.
- Using different English defaults for the same key.
- Reusing keys for different messages (keys identify semantics, not just text).
Accessibility:
- Avoid color‑only cues; ensure messages are clear in any theme.
- Keep technical warnings concise and actionable.
- Create
src/i18n/package.nls.<locale>.json(e.g.,package.nls.pl.json). - Copy all keys from
package.nls.jsonand translate values. - Keep placeholders
{0}intact and in order. - Build and run to verify (see Testing below). Packaging will copy files to the root automatically.
Locale naming follows VS Code’s conventions (e.g., de, pt-br, zh-cn).
Local testing:
- Change VS Code display language via “Configure Display Language” or run the Extension Development Host with a locale, e.g.
--locale=fr. - Ensure manifest UI (command titles, settings descriptions) reflect translations.
- Trigger runtime strings (status bar, notifications, prompts) to verify placeholders and grammar.
Automation suggestions:
- Lint: verify all
manifest.*andruntime.*keys exist across locale files. - Coverage: compare values in
package.nls.jsonagainstlanguage.jsonto detect missing source phrases. - Build check: ensure
npm run vscode:prepublishcopiessrc/i18n/package.nls*.jsonto the root.
package.jsoncontains"l10n": "./package.nls.json"for VS Code to locate the base strings.- The
vscode:prepublishscript runs:npm run build && cp src/i18n/package.nls*.json .so Marketplace packages include all locales at the root. - No runtime network access is required; everything ships inside the
.vsix.
- Seeing English instead of your language: the key is missing in your locale file; fallback to English is expected.
- Placeholders not replaced: ensure the message uses
{0}style tokens and code passes arguments tolocalize(...). - Incorrect grammar or spacing: propose an update to the relevant
package.nls.<locale>.json.
Examples of frequently used keys and messages (see package.nls.json for the canonical list):
| Key | Example English |
|---|---|
runtime.status.tooltip |
Run String‑LE: Extract |
runtime.message.info.no-strings |
No strings found |
runtime.message.warn.large-file |
Large file detected ({0} bytes). Extraction may take longer. |
runtime.dialog.action.copy |
Copy only |
manifest.command.extract.title |
String‑LE: Extract |
manifest.settings.sort.mode.option.alpha-asc |
Alphabetical (A → Z) |
- No data leaves your machine for localization purposes.
- Telemetry is local‑only when enabled; it does not include message contents.
Project: Issues • Pull Requests • Releases • MIT License
Dev: Spec • Architecture • Development • Troubleshooting
Docs: Commands • Notifications • Status Bar • Config • Performance • I18N • Privacy