360 Secure SkillHub
360 安全技能中心

deepl-translate-node

该 Skill 调用 DeepL 文本翻译 API,将命令行传入的文本翻译为指定目标语言,支持自动检测源语言、语言代码选择、可选术语字面替换,并在缺少密钥或 API 错误时给出排查提示。需要 Node 18+ 和 DeepL API 密钥。

分类:效率
rockbenben
rockbenben
热度 67.71
最近更新 2026-12-02 14:18:37

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add rockbenben/deepl-translate-node
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
deepl-translate-node
description
Translate with DeepL on explicit request or cross-check ambiguous wording when a mistranslation has material consequences. 指定使用 DeepL 翻译,或核对高风险歧义译法。
metadata
{"version":"1.1.17","openclaw":{"homepage":"https://github.com/rockbenben/aishort-skills/tree/main/skills/deepl-translate-node","emoji":"🔤","requires":{"bins":["node"],"env":["DEEPL_API_KEY"]},"primaryEnv":"DEEPL_API_KEY","envVars":[{"name":"DEEPL_API_HOST","required":false,"description":"Point at api.deepl.com for a Pro key; the Free host is the default."}],"files":["translate.mjs"]}}

DeepL Translate

Guardrails & Data Flow

  • When to call: Use DeepL only on explicit request or high-stakes ambiguity; proper names, jargon, idioms, or less-familiar pairs are cues to assess uncertainty, not automatic triggers.
  • External data & secrets: translate.mjs reads DEEPL_API_KEY and sends text over HTTPS to DeepL (api-free.deepl.com by default; DEEPL_API_HOST=api.deepl.com bare hostname without https:// for Pro keys). Send only content authorized for external processing, and never print or embed the API key in text or command output.
  • Critical verification: Treat DeepL output as another candidate translation, not proof of correctness. Reconcile discrepancies against source context or official terminology and flag remaining ambiguity.

1. Check Credentials

Verify key presence without printing its value:

# Bash
if [ -n "${DEEPL_API_KEY//[[:space:]]/}" ]; then echo "DEEPL_API_KEY is set"; else echo "DEEPL_API_KEY is missing"; fi
# PowerShell
if ([string]::IsNullOrWhiteSpace($env:DEEPL_API_KEY)) { 'DEEPL_API_KEY is missing' } else { 'DEEPL_API_KEY is set' }

If missing, stop and instruct the user to set DEEPL_API_KEY (export DEEPL_API_KEY="..." or $env:DEEPL_API_KEY = "..."; persistent shell config is optional).

2. Translate

Requires Node 18+. Replace {SKILL_DIR} with this skill's installed directory and quote paths:

node "{SKILL_DIR}/translate.mjs" --target ZH-HANS --text "The plaintiff filed a motion to compel discovery."
node "{SKILL_DIR}/translate.mjs" --source JA --target EN-US --text "持分会社"
  • Pass the text itself with --text or -t. To translate a literal flag, use an attached value such as --text=-t or --text=--help. Whitespace-only input is rejected before sending. Other text goes to DeepL with its original spacing.
  • Set --target / --target-lang to the requested language. Omit --source / --source-lang for auto-detection.
  • Output & timeout: Stdout outputs only the translation with paragraphs preserved; failures print ERROR: to stderr and exit non-zero. Requests time out at 60s (respect shorter task deadlines).
  • Optional --glossary 'term=translation;term=translation': Performs literal, case-sensitive substring replacement on DeepL's output (not DeepL's Glossary API). Example: API=接口 also rewrites APIs. Avoid ; inside terms; pairs without = are skipped with a stderr warning.

3. Language Codes & Error Triage

  • Targets: Follow the user's requested locale; common precise codes include ZH-HANS, ZH-HANT, EN-US, EN-GB, PT-BR, PT-PT.
  • Uncertain language support: Do not rely on an outdated static list — query GET https://<host>/v3/languages?resource=translate_text with Authorization: DeepL-Auth-Key <key> (resource is required; entries distinguish usable_as_source / usable_as_target, returning BCP 47 codes while translate.mjs also accepts uppercase). Text translation calls /v2/translate. Branch on HTTP status, not exact error wording (supported languages).
Error Action
403 Check DEEPL_API_KEY, DEEPL_API_HOST (Free vs Pro), and key permission scope.
456 Quota, Cost Control, or key-level limit reached — check the DeepL console.
400 / unsupported language Check the API error body, target variant, and live /v3/languages support.
Timeout / network error Check connectivity and DEEPL_API_HOST before retrying.