Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Implements VS Code localization infrastructure to enable future multi-language support for all user-facing strings.

Changes

Localization Infrastructure

  • src/strings.ts - Centralized l10n module with HTML escaping for security
  • package.nls.json - Package metadata localization (command titles, settings descriptions)
  • l10n/bundle.l10n.json - Runtime translations (English baseline)

String Extraction

  • Replaced hardcoded strings in typeCommand.ts, highScoreCommand.ts, shareStatsCommand.ts
  • Updated package.json to reference localization keys using %key% syntax
  • Template strings use VS Code standard {0}, {1} placeholders

Security

  • HTML escaping function prevents XSS in user-provided content (error messages)
  • Template-based approach separates translatable text from markup

Example Usage

// Before
vscode.window.showInformationMessage(
    `High Scores - Keystrokes: ${highScore} keys/sec | WPM: ${wpmScore} words/min`
);

// After
vscode.window.showInformationMessage(
    strings.highScore.displayMessage(String(highScore), String(wpmScore))
);

Adding New Languages

Contributors can add translations without code changes:

  1. Create l10n/bundle.l10n.{locale}.json (e.g., bundle.l10n.es.json)
  2. Create package.nls.{locale}.json
  3. VS Code auto-selects based on user locale

See docs/LOCALIZATION.md for guidelines.

Version: 1.1.4 → 1.2.0 (new feature)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/typingspeedometer/typingspeedometer/node_modules/.bin/vscode-test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Add localization strings


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 6 commits January 19, 2026 02:09
- Bump version to 1.2.0
- Install @vscode/l10n package for VS Code localization
- Create localization strings module (src/strings.ts)
- Add package.nls.json for package.json localization
- Add l10n/bundle.l10n.json for runtime string translations
- Replace hardcoded strings in typeCommand.ts with localized versions
- Replace hardcoded strings in highScoreCommand.ts with localized versions
- Replace hardcoded strings in shareStatsCommand.ts with localized versions
- Update package.json to use localized strings for commands and configuration
- Update CHANGELOG.md with version 1.2.0

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
…ent XSS

- Rename parameters in strings.ts for clarity (keysPerSec -> keysPerSecond)
- Add HTML escaping function to prevent XSS vulnerabilities
- Remove HTML tags from localized strings, apply formatting in code
- Update bundle.l10n.json to match new strings without HTML

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
- Use separate localized strings for formatted parts (Copy Image, hashtag)
- Use {0}, {1} placeholders in localized strings instead of hardcoded text
- Apply HTML formatting through template replacement instead of string matching
- Makes localization more robust and translation-friendly
- Update bundle.l10n.json with new template-based strings

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
- Change all placeholder formats from ${0}, ${1} to {0}, {1}
- Aligns with VS Code l10n standard conventions
- Update bundle.l10n.json to match correct placeholder format
- Ensures proper localization functionality

Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot AI changed the title [WIP] Add localization strings for internationalization Add localization support with @vscode/l10n Jan 19, 2026
Copilot AI requested a review from edvilme January 19, 2026 02:20
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.

2 participants