Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

xtrans

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xtrans

Minimalist AI-powered terminal translator / 极简 AI 终端翻译工具

latest
Source
npmnpm
Version
1.2.1
Version published
Weekly downloads
5
-68.75%
Maintainers
1
Weekly downloads
 
Created
Source

xtrans

极简主义的 AI 终端翻译工具。
支持本地大模型 (Ollama, LM Studio) 与主流在线 API。

中文 | English

Version Downloads/week License

核心亮点

  • 🔒 本地模型支持: 原生支持 OllamaLM Studio。无需联网,保护隐私。
  • 🌍 多服务商: 内置 OpenAI, DeepSeek, Kimi (Moonshot) 以及 Ollama/LM Studio 支持。
  • 🛠 高度可扩展: 轻松添加任何兼容 OpenAI 格式 的 API 服务。
  • 🤖 自动发现: 自动获取服务商的模型列表(例如读取你的 ollama list)。
  • 极简体验: 仅需输入 t <text> 即可快速翻译,或进入交互模式连续使用。

安装

npm install -g xtrans

或者使用 npx 直接运行:

npx xtrans <text>

使用指南

1. 快速翻译

全局安装后,可直接使用 txtrans 进行即时翻译;使用 npx 时请用 xtrans

t hello
# ┌───────────────────────────────────────────────────┐
# │  hello  /həˈləʊ/  int.  n.                        │
# │                                                   │
# │  int.                                             │
# │  • 你好 (用于问候、接电话或引起注意)              │
# │    - Hello, Paul. I haven't seen you for ages.    │
# │                                                   │
# │  n.                                               │
# │  • (Hello) 人名;(法)埃洛                       │
# │                                                   │
# │  Synonyms: hi, greetings                          │
# └───────────────────────────────────────────────────┘

2. 交互模式 (REPL)

不带参数运行即可进入交互式 shell(全局安装可用 txtrans;npx 请用 xtrans)。支持上下键 (↑/↓) 切换历史记录。

t
# Welcome to xtrans v1.2.0
# Provider: ollama | Model: llama3 | Target: zh
# › 

可用模式

在 REPL 内使用 /mode 切换,例如:t /mode cambridge

  • translation: 通用翻译
  • cambridge: 剑桥词典风格(学习者友好)
  • oxford: 牛津词典风格(学术/历史)
  • grammar: 语法检查

3. 管理命令

你可以在交互模式内 (输入 /) 或直接从终端运行这些命令。

命令说明示例
/use切换服务商或模型 (交互式)t /use
/mode切换模式 (translation/cambridge/oxford/grammar)t /mode oxford
/target设置目标语言t /target ja
/status检查服务状态及当前模型t /status
/add添加自定义 OpenAI 兼容服务商t /add
/remove移除服务商t /remove
/clean清理历史记录/缓存t /clean

支持的服务商

xtrans 为主流服务预设了配置模板:

🏠 本地 (隐私优先)

  • Ollama: 默认地址 http://localhost:11434。支持自动检测已安装模型。
  • LM Studio: 默认地址 http://localhost:1234/v1

☁️ 云端 API

  • OpenAI: 标准支持。
  • DeepSeek: 深度求索 API 支持。
  • Kimi (Moonshot): 月之暗面支持。
  • Custom (自定义): 添加任何支持 OpenAI Chat Completion 格式的服务。

配置

首次运行时,xtrans 会引导你设置首选服务商。你可以随时使用 t /use 进行切换。

如需添加自定义服务商(例如本地服务器或其他 API):

t /add

许可证

MIT

Keywords

oclif

FAQs

Package last updated on 04 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts