i18n Locale Lens
Jump from i18n keys in code to their exact JSON locale definitions.
Put the cursor on an i18n key, press F12 or Cmd/Ctrl-click it, and jump directly to the matching key in your locale JSON.
Features
- Supports JavaScript, TypeScript, JSX, and TSX by default.
- Can be enabled for any VS Code language ID through settings.
- Works with nested JSON objects and dot-separated keys.
- Supports i18next-style namespaces such as
auth:login.title.
- Supports configurable locale path templates.
- Can search multiple locales and multiple namespace files.
Default Behavior
The default configuration supports projects with this structure:
public/locales/ru/common.json
public/locales/ru/auth.json
public/locales/en/common.json
Examples:
t('common.button.ok');
t('lesson.call dialog.ready to start lesson');
t('auth:login.title');
Settings
{
"i18nJsonGotoDefinition.enabledLanguageIds": ["typescript", "typescriptreact", "javascript", "javascriptreact"],
"i18nJsonGotoDefinition.locales": ["ru"],
"i18nJsonGotoDefinition.pathTemplates": ["public/locales/{locale}/{namespaceFile}.json"],
"i18nJsonGotoDefinition.defaultNamespace": "translation",
"i18nJsonGotoDefinition.namespaceFileMap": {
"translation": "common",
"common": "common"
},
"i18nJsonGotoDefinition.namespaceSeparator": ":",
"i18nJsonGotoDefinition.keySeparator": ".",
"i18nJsonGotoDefinition.searchAllNamespaceFilesForKeysWithoutNamespace": true,
"i18nJsonGotoDefinition.ignoreTemplateStringsWithExpressions": true
}
Path Template Placeholders
{locale} and {language} are replaced with values from i18nJsonGotoDefinition.locales.
{namespace} is replaced with the namespace from the key.
{namespaceFile} is replaced with namespaceFileMap[namespace], or with the namespace itself when there is no mapping.
Configuration Examples
Single JSON file per locale:
{
"i18nJsonGotoDefinition.locales": ["ru", "en"],
"i18nJsonGotoDefinition.pathTemplates": ["locales/{locale}.json"],
"i18nJsonGotoDefinition.defaultNamespace": "translation",
"i18nJsonGotoDefinition.namespaceFileMap": {
"translation": "{locale}"
}
}
Namespace folders:
{
"i18nJsonGotoDefinition.locales": ["ru"],
"i18nJsonGotoDefinition.pathTemplates": ["src/i18n/{locale}/{namespaceFile}/index.json"],
"i18nJsonGotoDefinition.namespaceFileMap": {
"translation": "common",
"auth": "auth"
}
}
Enable all file types:
{
"i18nJsonGotoDefinition.enabledLanguageIds": []
}