← 返回 Skills 市场
baidu-translate

Baidu Text Translate

作者 baidu-translate · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
173
总下载
3
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install baidu-text-translate
功能描述
Translate text using Baidu AI Translation API via trans-cli with Baidu-specific language codes, API key management, error handling, and environment diagnostics.
使用说明 (SKILL.md)

baidu_text_translate — Agent Reference

trans text wraps the Baidu AI Translation API. Use --json — it separates success (stdout) from errors (stderr) and gives you structured fields to act on.

trans text --json "你好世界"                             # auto-detect → English
trans text --json --from zh --to jp "你好"               # explicit languages
trans text --json --to fra --reference "使用正式语气" "你好"  # custom instruction
echo "早上好" | trans text --json                        # stdin pipe

Environment Diagnosis

Before translating, verify the environment with trans doctor:

trans doctor           # human-readable output
trans doctor --json    # JSON output for Agent parsing

JSON contract (stdout):

{
  "checks": [
    {"name":"api_key",     "ok":true,  "source":"env/config", "message":"configured"},
    {"name":"connectivity","ok":true,  "latency_ms":243,       "message":"reachable"},
    {"name":"account",     "ok":true,                          "message":"valid"}
  ],
  "all_ok": true
}
Exit all_ok Meaning
0 true All checks passed — ready to translate
2 false At least one check failed — inspect checks[].ok

When a check fails, help_url in the failing check points to the fix:

  • api_key.ok:false → set TRANS_API_KEY (see Configuration below)
  • account.ok:false → key invalid/expired or quota exhausted

Run trans doctor --json as the first step when diagnosing any trans-cli failure.


JSON Contract

Success (stdout, exit 0):

{"from":"zh","to":"en","source":"你好","translated":"Hello"}
Field Note
from API-detected language — may differ from --from auto
to Target language
source Original input
translated Result

Error (stderr, exit ≠ 0):

{"code":"AUTH_FAILED","message":"…","help_url":"https://…","raw_code":"52001"}

help_url and raw_code are omitted when not applicable.


Error Decision Tree

Exit code Cause Action
0 OK Use translated
1 INVALID_INPUT Empty text Fix input, don't retry
1 INVALID_LANGUAGE Wrong lang code (e.g. ja → should be jp) Fix --to/--from, see Language Codes below
2 CONFIG_MISSING TRANS_API_KEY not set Stop — run trans doctor --json then guide user to set up API key
2 AUTH_FAILED Key invalid/expired (raw_code 52001–52003) Stop — run trans doctor --json then guide user to API key page
3 QUOTA_EXCEEDED Balance = 0 Stop — guide user to recharge (see below)
3 RATE_LIMITED QPS exceeded Wait 1 s, retry once
3 API_ERROR Unexpected API error Retry once; if persists, report raw_code + message
4 NETWORK_ERROR No connectivity Retry twice with 2 s gap; if persists, report

Exit 2 requires human intervention — the agent cannot fix auth or config. Exit 1 means the agent passed bad arguments — fix the call, not the environment.


Language Codes

Baidu does not follow ISO 639. When unsure of a code, query locally:

trans languages                    # full list (200+ languages)
trans languages --filter jp        # search by code
trans languages --filter 日语      # search by name
trans languages --json             # JSON output for Agent parsing

The six most common ISO traps:

Baidu (correct) ISO (wrong for Baidu) Language
jp ja Japanese
kor ko Korean
fra fr French
spa es Spanish
ara ar Arabic
vie vi Vietnamese

Other common codes that match ISO: zh cht en ru de pt it nl hi th Use auto for source-language auto-detection.


Configuration

Priority: --api-key flag > TRANS_API_KEY env > ~/.trans-cli/config.json

Config file field: api_key.

trans config init               # create empty config skeleton (~/.trans-cli/config.json)
trans config init --force       # overwrite existing config
trans config set api_key \x3CKEY>  # write api_key (creates file if absent)

Getting an API Key (First-Time Setup)

Guide the user through these steps — the agent cannot do this on their behalf:

  1. Open the Baidu Translation Open Platform and sign in: \x3Chttps://fanyi-api.baidu.com/>
  2. Go to Developer Center: \x3Chttps://fanyi-api.baidu.com/manage/developer>
  3. Click "Use Now" → select "General Translation" → complete identity verification
  4. Get your API Key: \x3Chttps://fanyi-api.baidu.com/manage/apiKey>
  5. Write to config: trans config set api_key \x3CKEY> or set the environment variable TRANS_API_KEY
  6. Verify: trans doctor --jsonall_ok:true means success

Recharging (QUOTA_EXCEEDED)

Recharge portal: \x3Chttps://fanyi-api.baidu.com/manage/account> Takes effect immediately — no restart needed. Auto-renewal can be enabled on the same page. Usage details: \x3Chttps://fanyi-api.baidu.com/api/trans/user/usage>


Non-Obvious Behaviours

  • Multiple positional args join with a space: trans text hello world"hello world"
  • When both stdin and positional args are given, positional args win silently
  • The from field in JSON is the API's detected language, not the --from flag value
  • trans doctor checks are short-circuit: if api_key fails, connectivity/account are skipped
  • --reference is optional; omitting it sends no extra field to the API
安全使用建议
This skill appears to be a legitimate wrapper for Baidu translation, but two things you should verify before installing or trusting it: (1) Confirm the authoritative requirements — the registry manifest shows no install/env, while SKILL.md says it needs the 'trans' CLI, TRANS_API_KEY, and suggests installing '@bdtrans/trans-cli' via npm. That mismatch could be an oversight or a packaging error. (2) If you need to install the npm package, review its npm/GitHub page and source code (or use an official client) before installing; installing arbitrary npm packages can introduce supply-chain risk. Also prefer setting TRANS_API_KEY in a limited-scope way (not a global secret store), and be aware the skill will run trans-cli commands and may create/modify ~/.trans-cli/config.json. If you want this skill, manually inspect or vet the npm package and consider installing trans-cli yourself rather than letting the agent do it automatically.
能力标签
requires-sensitive-credentials
能力评估
Purpose & Capability
The skill's name and instructions match its stated purpose (wrapping the Baidu Translation API via trans-cli). Requiring a trans CLI binary and a TRANS_API_KEY is proportionate to the functionality. However, the registry-level manifest (Requirements section) shows no required binaries or env vars while the SKILL.md contains embedded metadata that declares 'trans' and TRANS_API_KEY as requirements and an npm install recipe — that inconsistency is unexpected.
Instruction Scope
Runtime instructions are narrowly scoped to running trans-cli commands (trans text, trans doctor, trans languages, trans config) and reading/writing the skill's config file (~/.trans-cli/config.json). The SKILL.md explicitly prevents the agent from obtaining an API key itself and limits actions to diagnostics, retries, and guidance. There are no instructions to read unrelated system files or exfiltrate data.
Install Mechanism
The registry manifest lists no install spec, but SKILL.md metadata includes an npm install (package '@bdtrans/trans-cli'). This mismatch is concerning because the skill is instruction-only in the registry but references installing a third-party npm package (moderate risk). The npm package name is not validated here; installing an arbitrary npm package and placing binaries on PATH carries supply-chain risk and should be reviewed before use.
Credentials
The only credential/environment variable referenced in SKILL.md is TRANS_API_KEY (and a local config file). That is proportionate to the stated purpose. The concern is the manifest mismatch: the top-level Requirements reported none, while the SKILL.md metadata declares TRANS_API_KEY — verify which is authoritative before granting secrets.
Persistence & Privilege
The skill does not request 'always:true' and does not claim system-wide privilege. It may write to its own config file (~/.trans-cli/config.json) which is normal for a CLI integration. There is no indication it attempts to alter other skills or global agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install baidu-text-translate
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /baidu-text-translate 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
- Added required TRANS_API_KEY environment variable to skill metadata. - No other changes to skill logic or documentation.
v1.0.0
- Initial release of baidu-text-translate skill. - Enables text translation via the trans-cli tool using Baidu Translation AI API. - Supports JSON output, Baidu-specific language codes (e.g., jp, kor, fra, spa, ara), and error handling based on exit codes and API responses. - Includes guidance for API key setup, quota issues, and environment diagnosis using trans doctor. - Provides tools for listing and searching supported languages with correct Baidu codes. - Details non-standard behaviors and configuration priorities for seamless translation workflow.
元数据
Slug baidu-text-translate
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Baidu Text Translate 是什么?

Translate text using Baidu AI Translation API via trans-cli with Baidu-specific language codes, API key management, error handling, and environment diagnostics. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 173 次。

如何安装 Baidu Text Translate?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install baidu-text-translate」即可一键安装,无需额外配置。

Baidu Text Translate 是免费的吗?

是的,Baidu Text Translate 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Baidu Text Translate 支持哪些平台?

Baidu Text Translate 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Baidu Text Translate?

由 baidu-translate(@baidu-translate)开发并维护,当前版本 v1.0.1。

💬 留言讨论