Skip to content

feat: add Brazilian Portuguese (pt-BR) localization#202

Open
corazzione wants to merge 2 commits intoyoavbls:mainfrom
corazzione:feat/pt-br-localization
Open

feat: add Brazilian Portuguese (pt-BR) localization#202
corazzione wants to merge 2 commits intoyoavbls:mainfrom
corazzione:feat/pt-br-localization

Conversation

@corazzione
Copy link
Copy Markdown
Contributor

Summary

Adds full Brazilian Portuguese (pt-BR) i18n support using the standard @vscode/l10n API (available since VS Code 1.73).

Closes #144

What changed

  • apps/vscode-extension/package.json — added "l10n": "./l10n" so VS Code auto-loads locale bundles
  • packages/vscode-formatter/package.json — added @vscode/l10n dependency
  • apps/vscode-extension/l10n/bundle.l10n.pt-BR.json — 12 translated strings (new file)
  • packages/vscode-formatter/src/components/actions.ts — wrapped 5 tooltip titles with l10nT()
  • packages/vscode-formatter/src/components/errorTitle.ts — wrapped "Error" label
  • apps/vscode-extension/src/provider/webviewViewProvider.ts — wrapped 4 UI strings
  • apps/vscode-extension/src/commands/copyError.ts — wrapped clipboard notification
  • apps/vscode-extension/src/provider/markdownWebviewProvider.ts — injects window.__i18n into webview HTML with translated strings
  • apps/vscode-extension/webview/index.js — reads from window.__i18n (webview has no direct access to VS Code l10n API)

How it works

VS Code detects the user's display language and automatically loads the matching bundle.l10n.{locale}.json from the l10n/ folder declared in package.json. No configuration needed by the user. Falls back to English for any other locale.

Adding support for additional languages only requires a new bundle.l10n.{locale}.json file — no code changes needed.

Test plan

  • Set VS Code display language to pt-BR (Configure Display Language command)
  • Open a TypeScript file with a type error
  • Verify hover tooltip shows "⚠ Erro" and translated action titles
  • Open the side panel and verify empty state message is in Portuguese
  • Pin an error and verify "Erro fixado" / "Desafixar erro" labels
  • Click copy button and verify "Tipo copiado para a área de transferência!" notification

Implements i18n support using the @vscode/l10n API (VS Code standard
since v1.73) and adds a complete pt-BR translation bundle.

Changes:
- Add `"l10n": "./l10n"` to extension package.json so VS Code picks up
  locale bundles automatically
- Add @vscode/l10n dependency to @pretty-ts-errors/vscode-formatter
- Wrap all user-facing UI strings with l10n.t() / vscode.l10n.t():
  - Tooltip titles in actions.ts (5 strings)
  - "⚠ Error" label in errorTitle.ts
  - Empty state, pinned error labels in webviewViewProvider.ts
  - Clipboard notification in copyError.ts
- Inject translated strings into webview HTML via window.__i18n so the
  sandboxed webview context can also display localized text
- Add apps/vscode-extension/l10n/bundle.l10n.pt-BR.json with 12
  Brazilian Portuguese translations

Closes yoavbls#144
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.

Tracking: Internationalization and localization

1 participant