---
title: "vscode-extension"
description: "The preset for VS Code extensions. It reads vscode.l10n.t, package.nls.json files and l10n bundles."
canonical_url: "https://x18n.dev/presets/vscode-extension"
---
# vscode-extension

> The preset for VS Code extensions. It reads vscode.l10n.t, package.nls.json files and l10n bundles.

The `vscode-extension` preset supports the localization of [VS Code extensions](https://code.visualstudio.com/api/references/vscode-api#l10n): `vscode.l10n.t` in code, and `%key%` references in `package.json`.

## Detection

The preset applies when the project depends on `vscode` or `@types/vscode`.

```ts [x18n.config.ts]
import { defineConfig } from '@x18n/core'

export default defineConfig({
  presets: ['vscode-extension'],
})
```

## Locale files

The preset adds a locale finder for the two file layouts of VS Code:

| File                                                           | Locale            |
| -------------------------------------------------------------- | ----------------- |
| `package.nls.json`                                             | The source locale |
| `package.nls.<locale>.json`, for example `package.nls.de.json` | `<locale>`        |
| `l10n/bundle.l10n.json`                                        | The source locale |
| `l10n/bundle.l10n.<locale>.json`                               | `<locale>`        |

The finder looks for these names in any directory, except `node_modules`.

## Supported syntax

`l10n.t` and `vscode.l10n.t` are translate calls:

```ts
import { l10n } from 'vscode'

l10n.t('Hello {0}', name)
```

The preset also adds a regex scanner for JSON files. It reads `"%key%"` references, so the strings of `package.json` count as usages:

```json [package.json]
{
  "contributes": {
    "commands": [
      { "command": "ext.hello", "title": "%command.hello%" }
    ]
  }
}
```

## Placeholders

Braces: `{0}`, `{name}`.


## Sitemap

See the full [sitemap](https://x18n.dev/sitemap.md) for all pages.
