Localness for VS CodeShows Localness translation keys where you use them, edits their translations and syncs the locale files. Requires a Localness personal access token. Features
Editing, extracting and pushing need a Read & write token. Only the source locale and the display locale are downloaded. Data is kept in memory and cached under the extension's global storage; the cache is shown immediately and refreshed in the background, when the window regains focus, and on Getting started
The extension only uses the signed-in token; it does not read Sign in writes the base URL and project to
The extension uses the nearest Project configuration (
|
| Field | Default | Description |
|---|---|---|
baseUrl |
required | Localness instance URL. |
project |
none | Project id or name. Missing: the token's only project. |
keyPatterns |
[] |
Extra regular expressions finding keys; the key is capture group 1. |
useDefaultKeyPatterns |
true |
Keep the built-in patterns alongside keyPatterns. |
extractTemplates |
see below | Code written by Extract to Localness, per site. |
release |
none | Release that keys created by extract or push are labelled with; set it from the status bar. |
files, locales, ... |
Local locale files, shared with the CLI; see the @localness/cli README. |
extractTemplates overrides any of these; {key} is the key and {attr} the attribute name. An entry without {key} is ignored:
{
"extractTemplates": {
"vueText": "{{ $t('{key}') }}",
"vueAttr": ":{attr}=\"$t('{key}')\"",
"vueExpr": "$t('{key}')",
"jsxText": "{t('{key}')}",
"jsxAttr": "{attr}={t('{key}')}",
"script": "t('{key}')"
}
}
Settings
Personal display preferences stay in VS Code settings:
| Setting | Default | Description |
|---|---|---|
localness.displayLocale |
"" |
Locale shown in hovers and hints. Empty: first non-source locale. |
localness.inlineHints |
"inline" |
"inline", "replace" or "off". |
localness.inlineHintStyle |
"inlay" |
"inlay", "dot", "arrow" or "plain". |
localness.replaceRevealOn |
"line" |
Reveal replaced keys by cursor "line" or by "cursor" on key. |
localness.inlineHintMaxLength |
40 |
Truncation length of inline hints. |
localness.keyUnderline |
true |
Underline keys that exist in the project. |
localness.diagnostics |
true |
Warn about unknown keys. |
localness.languages |
typescript, typescriptreact, javascript, javascriptreact, vue, html |
Language ids in which keys are recognised. |
localness.cliCommand |
"localness" |
How the Local Files view runs the CLI, e.g. npx localness. |
Key detection
Built-in patterns recognise t('key'), $t('key'), this.$t('key'), i18n.t('key'), i18n.global.t('key') and <i18n-t keypath="key">, with single, double or backtick quotes. Template literals containing ${} and bound attributes (:keypath) are ignored as dynamic. Detection is regex based, not AST based.
Custom pattern example in localness.config.json (a tr("key") helper):
{ "keyPatterns": ["\\btr\\(\"([^\"\\n]+)\"\\)"] }
Namespaces
The Keys view groups keys by the namespaces the project declares (from /api/v1/meta). Names are relative to the project's key prefix: a key belongs to the namespace that what follows its prefix starts with, followed by one of _ . - : / (a key without the prefix is matched whole). Without declared namespaces keys group by their first segment after the prefix.
Development
pnpm install
pnpm --filter localness-vscode build
Open the repository in VS Code and press F5 with the packages/vscode folder as the extension development path.