Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Comment Translate: LM StudioNew to Visual Studio Code? Get it now.
Comment Translate: LM Studio

Comment Translate: LM Studio

Mike Lucis

| (0) | Free
LM Studio local LLM translate source for Comment Translate
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

LM Studio Comment Translate

为 Comment Translate 提供 LM Studio 本地翻译源。

实现方式参考官方 Wiki:翻译服务。

前置条件

  1. 已安装并启用 Comment Translate(intellsmi.comment-translate)
  2. 已安装 LM Studio,并在 Developer 页开启本地服务器(默认 http://localhost:1234)
  3. 在 LM Studio 中加载至少一个聊天模型

安装

npm install
npm run compile
npx vsce package --no-dependencies
cursor --install-extension .\lmstudio-comment-translate-0.1.0.vsix

安装后请 Reload Window。

使用

  1. Ctrl+Shift+P → 执行 Comment Translate: Change translation source
  2. 选择 LM Studio translate
  3. 正常使用 Hover / 沉浸式阅读等翻译功能

也可在设置中写入:

{
  "commentTranslate.source": "MikeLucis.comment-translate-lmstudio-lmstudio",
  "commentTranslate.targetLanguage": "zh-CN",
  "lmstudioTranslate.apiStyle": "native",
  "lmstudioTranslate.baseUrl": "http://localhost:1234",
  "lmstudioTranslate.model": "hy-mt2-1.8b"
}

默认走 LM Studio 原生接口,等价于:

curl http://localhost:1234/api/v1/chat \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hy-mt2-1.8b",
    "system_prompt": "...",
    "input": "..."
  }'

配置项

配置 默认值 说明
lmstudioTranslate.baseUrl http://localhost:1234 LM Studio 服务根地址
lmstudioTranslate.apiStyle native native=/api/v1/chat,openai=/v1/chat/completions
lmstudioTranslate.apiKey lm-studio Bearer Token
lmstudioTranslate.model hy-mt2-1.8b 调用的模型名;可改成任意已加载模型
lmstudioTranslate.systemPrompt (见设置) 支持 {from} {to}
lmstudioTranslate.userPrompt (见设置) 支持 {from} {to} {text}
lmstudioTranslate.temperature 0.2 采样温度
lmstudioTranslate.maxTokens 2048 最大生成 token
lmstudioTranslate.topP 1 top_p
lmstudioTranslate.timeoutMs 120000 请求超时(毫秒)

开发说明

插件通过 contributes.translates 声明服务,并在 activate 中返回:

{
  extendTranslate(registry) {
    registry('lmstudio', LmStudioTranslate);
  }
}

LmStudioTranslate 实现 comment-translate-manager 的 ITranslate,请求 LM Studio 的 /v1/chat/completions。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft