i18n View AngularInspect, preview, and navigate ngx-translate keys directly from Angular HTML templates and TypeScript source files.
The extension underlines recognized keys, shows every configured locale in a hover table, and opens the matching JSON property in the right locale file. Features
Supported translation patternsAngular HTML templates
TypeScript
|
| Property | Description |
|---|---|
locales |
Locale identifiers used in hover output and navigation. |
defaultLocale |
Locale opened by Ctrl+click and the default hover action. |
localesPaths |
One or more translation directories, relative to the workspace folder. Absolute paths are also accepted. |
translationMode |
global (one file per locale) or namespaced (one file per namespace and locale). |
pathMatcher |
Path template using {locale} and, for namespaced files, {namespaces}. |
Global layout
{
"translationMode": "global",
"pathMatcher": "{locale}.json"
}
src/assets/i18n/
├── en.json
├── fr.json
└── ca.json
The full key is resolved at once: tickets.settings.card_title looks up
tickets → settings → card_title inside en.json.
Namespaced layout
{
"translationMode": "namespaced",
"pathMatcher": "{namespaces}/{locale}.json"
}
src/assets/i18n/
├── tickets/
│ ├── en.json
│ └── fr.json
└── home/
├── en.json
└── fr.json
For tickets.settings.card_title:
- Namespace:
tickets - Property path:
settings.card_title - File:
src/assets/i18n/tickets/en.json
The first key segment is used as the namespace. If that file does not contain the
key, longer namespace prefixes are tried as a fallback, so nested namespace
directories such as tickets/settings/en.json also work.
If pathMatcher has no {namespaces} placeholder in namespaced mode, all keys
are read from one file per locale using the full nested key path.
Commands
| Command | Description |
|---|---|
i18n-view-angular.setup |
Create the configuration file interactively. |
i18n-view-angular.reload |
Reload configuration, translation data, and decorations. |
i18n-view-angular.openDefaultLocale |
Open the key under the cursor in the default locale. |
i18n-view-angular.openLocale |
Pick a locale and open the key under the cursor. |
Commands are available in the Command Palette with the i18n View Angular category. When the cursor is not on a key, the open commands offer a quick pick of keys found in the active template or TypeScript file.
How it works
- Translation detection is split by source type, then shared:
- Angular HTML detection finds a quoted string followed by the
translatepipe. - TypeScript detection uses a lightweight tokenizer rather than a whole-file
regular expression. It scans member calls, string literals, comments,
template literals, and regex literals, identifies
TranslateServiceimports and injection patterns, and records the exact string-literal range.
- Angular HTML detection finds a quoted string followed by the
- Dynamic HTML expressions and dynamic TypeScript keys are ignored.
- Hover, decorations, and navigation share the same detected key occurrences and
run for
.htmland.tsfiles. - The extension caches parsed JSON and property locations. A file is read only when a key resolves to it; caches are invalidated by file watchers and document edits. Detected source keys are cached per document version as well.
- Navigation computes the exact JSON property position, so the editor opens at the key rather than at the top of the file.
- Missing files, missing keys, invalid JSON, and read errors are reported in the hover table and through actionable warning messages.
Development
npm install
npm run compile # type check, lint, and bundle with esbuild
npm run test:unit # fast unit tests (no VS Code instance required)
npm test # VS Code integration test runner
Press F5 in VS Code to launch an Extension Development Host.
Project structure
src/
├── angular/keyDetector.ts # static translation pipe detection
├── detection/documentTranslationKeys.ts # HTML/TypeScript dispatch and cache
├── detection/typescript/ # tokenizer and TranslateService detection
├── config/config.ts # loading and validation
├── i18n/pathMatcher.ts # locale/namespace path resolution
├── i18n/jsonLocator.ts # JSON parsing with property positions
├── i18n/resolver.ts # global and namespaced key resolution
├── i18n/translationCache.ts # parsed-file cache, incl. unsaved documents
├── i18n/service.ts # workspace contexts, watchers, and reloads
├── providers/ # hover and go-to-definition providers
├── ui/decorationManager.ts # underline decorations
├── ui/markdown.ts # hover content and command links
├── commands.ts # setup, reload, and open commands
└── extension.ts # activation and wiring
The UX was informed by inspecting the installed lokalise.i18n-ally extension (ngx-translate usage regex, underline annotations, hover command links, and definition-provider navigation) while keeping this extension focused and small.
Limitations
- Only static single- and double-quoted translation keys are detected; dynamic keys, concatenated strings, template literals, and computed expressions are out of scope.
- TypeScript detection only supports direct
TranslateService.instant()calls. Other programmatic APIs such asget()andstream()are not detected. - TypeScript inline Angular component templates are out of scope.
- Hover and navigation run for
.htmland.tsfiles..tsxfiles are not scanned. - TypeScript detection is conservative when type information is incomplete and
only falls back to common receiver names such as
translateandtranslateService. - Translation files must be JSON.
- Keys are resolved case-sensitively.
- Only one translation layout is configured per workspace folder.