Skip to content

Configuration ​

Overview ​

SettingTypeDefaultDescription
enableFileTranslationbooleantrueEnable file path translation
translateNewFileContentbooleantrueAlso replace pre-translation names inside new file content
enableDigitFormatShortcutbooleantrueEnable trailing-digit format shortcut (a lone trailing 1-8 skips the format picker)
translationServicestring"copilot"Current translation service (copilot maps to Pinyin)
servicePrioritystring"copilot,openai,google,bing,deeplx,baidu,tencent"Service priority for fallback (high to low, comma-separated)
copyToClipboardbooleanfalseAuto-copy the result to the clipboard after translation
clipboardFormatsstring[][]Naming formats to write to the clipboard history
servicesobject{}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 (package declaration, 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:

  1. 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)
  2. After renaming, each pre-translation path segment (including directory segments, e.g. 用户→User, 信息→Information) is replaced in the file content and saved
  3. 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:

  1. 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)
  2. 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
  3. 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
  4. Digits are excluded from translation and the written result: creating 用户/信息1/用户2.java produces user/information/User.java (directories camelCase, file PascalCase; template content is replaced with User, not 用户2/User2); selecting 用户1 and translating leaves user in the document — the digit disappears with the selection
  5. The clipboard original (originalValue) also drops the digit: for 用户2.java it 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:

  • camelCase
  • PascalCase
  • snake_case
  • CONSTANT_CASE
  • param-case
  • Header-Case
  • Capital Case
  • no case
  • Sentence case
  • originalValue — 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"
    }
  }
}
ParameterDescriptionDefaultWhere to get
apiKeyOpenAI API Key (required)-https://platform.openai.com/api-keys
baseUrlAPI base URLhttps://api.openai.comAny OpenAI-compatible API
modelModel namegpt-3.5-turboAny OpenAI-compatible model

Google Translate ​

json
{
  "variableTranslator.services": {
    "google": {
      "apiKey": "your-google-api-key"
    }
  }
}
ParameterDescriptionWhere to get
apiKeyGoogle 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"
    }
  }
}
ParameterDescriptionDefaultWhere to get
apiKeyAzure Translator API Key (required)-https://portal.azure.com/
regionAzure Translator regionglobalYour Azure resource region

DeepLX ​

json
{
  "variableTranslator.services": {
    "deeplx": {
      "baseUrl": "http://127.0.0.1:1188"
    }
  }
}
ParameterDescriptionDefault
baseUrlDeepLX endpointhttp://127.0.0.1:1188

Baidu Translate ​

json
{
  "variableTranslator.services": {
    "baidu": {
      "appId": "your-app-id",
      "secretKey": "your-secret-key"
    }
  }
}
ParameterDescriptionWhere to get
appIdBaidu Translate APP_ID (required)https://fanyi-api.baidu.com/
secretKeyBaidu 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"
    }
  }
}
ParameterDescriptionDefaultWhere to get
secretIdTencent Cloud SecretId (required)-https://console.cloud.tencent.com/cam/capi
secretKeyTencent Cloud SecretKey (required)-https://console.cloud.tencent.com/cam/capi
regionService regionap-guangzhouSee 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:1188 with 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"
    }
  }
}

Released under the MIT License.