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: vscode.l10n.t in code, and %key% references in package.json.
Detection
The preset applies when the project depends on vscode or @types/vscode.
x18n.config.ts
import { vscodeExtension } from '@x18n/cli/presets'
import { defineConfig } from '@x18n/core'
export default defineConfig({
presets: [vscodeExtension()],
})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:
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:
package.json
{
"contributes": {
"commands": [
{ "command": "ext.hello", "title": "%command.hello%" }
]
}
}Placeholders
Braces: {0}, {name}.