Configuration
Overview
| Setting | Type | Default | Description |
|---|---|---|---|
enableFileTranslation | boolean | true | Enable file path translation |
translateNewFileContent | boolean | true | Also replace pre-translation names inside new file content |
enableDigitFormatShortcut | boolean | true | Enable trailing-digit format shortcut (a lone trailing 1-8 skips the format picker) |
translationService | string | "copilot" | Current translation service (copilot maps to Pinyin) |
servicePriority | string | "copilot,openai,google,bing,deeplx,baidu,tencent" | Service priority for fallback (high to low, comma-separated) |
copyToClipboard | boolean | false | Auto-copy the result to the clipboard after translation |
clipboardFormats | string[] | [] | Naming formats to write to the clipboard history |
services | object | {} | API keys / endpoints per service |
All settings are prefixed with variableTranslator. — search variableTranslator in VSCode Settings (Ctrl+,).
Settings in Detail
enableFileTranslation
- Type:
boolean - Default:
true - Description: Enables file path translation (translate on file/folder creation). Also toggled via
Alt+Shift+D
json
{
"variableTranslator.enableFileTranslation": true
}translateNewFileContent
- Type:
boolean - Default:
true - Description: Applies to newly created files only. Language servers (e.g. redhat.java) generate template content (
packagedeclaration, class name) based on the pre-translation file name. When enabled, path translation also replaces every pre-translation path segment in the content with its translated form. Renaming an existing file never touches its content
Behavior details:
- Before renaming, the dirty editor buffer is saved first, so a template inserted by a language server cannot be written back to the old path after the rename (which would leave both pre- and post-translation files on disk)
- After renaming, each pre-translation path segment (including directory segments, e.g.
用户→User,信息→Information) is replaced in the file content and saved - Within a 4-second settle window after the rename, if a language server belatedly writes the old-name template back to the old path, it is merged into the translated file and the resurrected old file is deleted
Example: creating 用户/信息/用户.java translates to User/Information/User.java, and the content becomes:
java
package User.Information;
public class User {
}json
{
"variableTranslator.translateNewFileContent": true
}enableDigitFormatShortcut
- Type:
boolean - Default:
true - Description: Enables the "trailing-digit format shortcut": a lone digit at the end of a name (1 through the number of format options) is treated as a format number, skipping the format picker
Rules:
- The digit maps to the same numbering as typing a number in the picker: 1=camelCase, 2=PascalCase, 3=snake_case, 4=CONSTANT_CASE, 5=param-case, 6=Header-Case; text scenarios add 7=Capital Case, 8=no case, 9=Sentence case (7/8/9 do not apply to file/folder names — the picker shows as usual)
- Every segment of the path (split by separators and dots, extension stripped first) is judged independently: a lone digit at a segment's end (previous character is not a digit, content precedes it) is that segment's format number; consecutive digits (
用户12) or a digit not at the end (用户1信息) stay part of the name - Directory and file formats are separate: the file segment's (last segment's) digit sets the file format, otherwise the picker shows and its choice applies only to the file segment and segments with nothing to inherit; a directory segment without a digit inherits the nearest downstream segment that has one; if the whole path has no digits, everything uses the picked format
- Digits are excluded from translation and the written result: creating
用户/信息1/用户2.javaproducesuser/information/User.java(directories camelCase, file PascalCase; template content is replaced withUser, not用户2/User2); selecting用户1and translating leavesuserin the document — the digit disappears with the selection - The clipboard original (
originalValue) also drops the digit: for用户2.javait is用户
json
{
"variableTranslator.enableDigitFormatShortcut": true
}translationService
- Type:
string - Default:
"copilot" - Values:
"copilot"|"openai"|"google"|"bing"|"deeplx"|"baidu"|"tencent" - Description: The translation service to use. Also switched via
Alt+Shift+S
copilot means Pinyin
copilot is a legacy value that actually maps to the Pinyin service (zero configuration, works offline). It shows up as "拼音 (Pinyin)" in the service picker.
json
{
"variableTranslator.translationService": "openai"
}servicePriority
- Type:
string - Default:
"copilot,openai,google,bing,deeplx,baidu,tencent" - Description: Fallback priority (high to low, comma-separated). When the current service fails, the next one is tried in this order; invalid names are filtered out
json
{
"variableTranslator.servicePriority": "openai,google,bing,deeplx,baidu,tencent"
}copyToClipboard
- Type:
boolean - Default:
false - Description: Auto-copy the result to the clipboard after translation (applies to both selection and file path translation)
json
{
"variableTranslator.copyToClipboard": true
}clipboardFormats
- Type:
string[] - Default:
[] - Description: Naming formats written to the clipboard history in order (the format you pick goes first)
Values:
camelCasePascalCasesnake_caseCONSTANT_CASEparam-caseHeader-CaseCapital Caseno caseSentence caseoriginalValue— the pre-translation text
json
{
"variableTranslator.clipboardFormats": [
"camelCase",
"originalValue",
"PascalCase",
"no case",
"snake_case",
"CONSTANT_CASE",
"param-case",
"Header-Case",
"Capital Case",
"Sentence case"
]
}services
- Type:
object - Default:
{} - Description: Per-service configuration (services that need no configuration can be omitted — Pinyin and DeepLX work without any)
json
{
"variableTranslator.services": {
"openai": {
"apiKey": "sk-xxx",
"baseUrl": "https://api.openai.com",
"model": "gpt-3.5-turbo"
},
"google": {
"apiKey": "your-google-api-key"
},
"bing": {
"apiKey": "your-api-key",
"region": "global"
},
"deeplx": {
"baseUrl": "http://127.0.0.1:1188"
},
"baidu": {
"appId": "xxx",
"secretKey": "xxx"
},
"tencent": {
"secretId": "xxx",
"secretKey": "xxx",
"region": "ap-guangzhou"
}
}
}Service Configuration
OpenAI
json
{
"variableTranslator.services": {
"openai": {
"apiKey": "your-api-key",
"baseUrl": "https://api.openai.com",
"model": "gpt-3.5-turbo"
}
}
}| Parameter | Description | Default | Where to get |
|---|---|---|---|
| apiKey | OpenAI API Key (required) | - | https://platform.openai.com/api-keys |
| baseUrl | API base URL | https://api.openai.com | Any OpenAI-compatible API |
| model | Model name | gpt-3.5-turbo | Any OpenAI-compatible model |
Google Translate
json
{
"variableTranslator.services": {
"google": {
"apiKey": "your-google-api-key"
}
}
}| Parameter | Description | Where to get |
|---|---|---|
| apiKey | Google Cloud Translation API Key (required) | Enable the Cloud Translation API in Google Cloud Console, then create a key |
Bing / Azure Translator
json
{
"variableTranslator.services": {
"bing": {
"apiKey": "your-api-key",
"region": "global"
}
}
}| Parameter | Description | Default | Where to get |
|---|---|---|---|
| apiKey | Azure Translator API Key (required) | - | https://portal.azure.com/ |
| region | Azure Translator region | global | Your Azure resource region |
DeepLX
json
{
"variableTranslator.services": {
"deeplx": {
"baseUrl": "http://127.0.0.1:1188"
}
}
}| Parameter | Description | Default |
|---|---|---|
| baseUrl | DeepLX endpoint | http://127.0.0.1:1188 |
Baidu Translate
json
{
"variableTranslator.services": {
"baidu": {
"appId": "your-app-id",
"secretKey": "your-secret-key"
}
}
}| Parameter | Description | Where to get |
|---|---|---|
| appId | Baidu Translate APP_ID (required) | https://fanyi-api.baidu.com/ |
| secretKey | Baidu Translate Secret Key (required) | https://fanyi-api.baidu.com/ |
Tencent Translator
json
{
"variableTranslator.services": {
"tencent": {
"secretId": "your-secret-id",
"secretKey": "your-secret-key",
"region": "ap-guangzhou"
}
}
}| Parameter | Description | Default | Where to get |
|---|---|---|---|
| secretId | Tencent Cloud SecretId (required) | - | https://console.cloud.tencent.com/cam/capi |
| secretKey | Tencent Cloud SecretKey (required) | - | https://console.cloud.tencent.com/cam/capi |
| region | Service region | ap-guangzhou | See Tencent region docs |
Services Requiring No Configuration
- Pinyin (
copilot): zero configuration, works offline, converts CJK characters to pinyin — the final safety net when all services fail - DeepLX: default endpoint
http://127.0.0.1:1188with automatic health checks (60s cache); just deploy it locally
Full Example
Copy what you need into settings.json:
json
{
// Enable file path translation (translate on file creation)
"variableTranslator.enableFileTranslation": true,
// Translation service: copilot(Pinyin) | openai | google | bing | deeplx | baidu | tencent
"variableTranslator.translationService": "openai",
// Fallback priority (high to low, comma-separated)
"variableTranslator.servicePriority": "copilot,openai,google,bing,deeplx,baidu,tencent",
// Auto-copy the result to the clipboard after translation
"variableTranslator.copyToClipboard": true,
// Naming formats written to the clipboard history in order
"variableTranslator.clipboardFormats": [
"camelCase",
"originalValue",
"PascalCase",
"no case",
"snake_case",
"CONSTANT_CASE",
"param-case",
"Header-Case",
"Capital Case",
"Sentence case"
],
// Per-service configuration (omit services you don't use)
"variableTranslator.services": {
"openai": {
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"baseUrl": "https://api.openai.com",
"model": "gpt-3.5-turbo"
},
"google": {
"apiKey": "your-google-api-key"
},
"bing": {
"apiKey": "your-api-key",
"region": "global"
},
"deeplx": {
"baseUrl": "http://127.0.0.1:1188"
},
"baidu": {
"appId": "your-app-id",
"secretKey": "your-secret-key"
},
"tencent": {
"secretId": "your-secret-id",
"secretKey": "your-secret-key",
"region": "ap-guangzhou"
}
}
}