translate-cli Practical Guide: Translate Files, Stdin, and Batch Globs with One Command
What This Skill Does One line: translate-cli is the most underrated productivity skill in the OpenClaw ecosystem . It lets you translate arbitrary text, stdi…
- Added to the lab
- Downloads
- 0
- Human review
- Human reviewed
What This Skill Does
One line: translate-cli is the most underrated productivity skill in the OpenClaw ecosystem. It lets you translate arbitrary text, stdin streams, single files, or entire directories of glob-matched files — with multi-provider support, preset configurations, custom prompt templates, and dry-run validation.
At SFD Lab, we use it to batch-translate articles to English and Traditional Chinese daily, enabling trilingual publishing on smallfiredragon.com.
Installation
clawhub install translate-cliVerify installation:
translate --version
# translate-cli v1.x.xBasic Usage
Translate Text
# Direct text translation
translate "深度学习入门指南"
Specify target language
translate --lang en "深度学习入门指南"
→ Introduction to Deep Learning
Stdin Input
# Pipe input
echo "Context window technology" | translate --lang zh
From file
cat article.txt | translate --lang zh-TW > article_tw.txt
Translate a Single File
translate --file ./docs/readme.md --lang en --out ./docs/readme_en.mdBatch Translation (Glob)
# Translate all markdown files in a directory
translate --file "./content/*.md" --lang en --out-dir ./content_en/
Output:
✓ article-1.md → article-1.md (en)
✓ article-2.md → article-2.md (en)
✓ 12 files translated in 18.3s
Provider Selection
translate-cli supports multiple AI providers. Configure in .openclaw/config.toml:
[translate]
default_provider = "openai" # openai | anthropic | deepseek | gemini
default_model = "gpt-4o-mini" # budget-friendly default
Override per-command:
translate --provider anthropic --model claude-haiku "Hello world"
translate --provider deepseek "Quantum computing basics"Pro tip from our experience: DeepSeek handles Chinese technical documentation best for zh→en. For en→zh, GPT-4o-mini produces more natural-sounding output. Pick your provider by direction, not just cost.
Presets — The Killer Feature
Most people skip this. Presets let you codify language pairs, models, and prompt styles:
# List existing presets
translate presets list
Create a preset
translate presets add tech-zh-to-en
--from zh
--to en
--provider openai
--model gpt-4o
--prompt "Translate Chinese technical content to English. Preserve all code blocks, technical terms, and markdown formatting exactly."
Use the preset
translate --preset tech-zh-to-en --file article.md
Our three core presets at SFD Lab:
sfd-zh-to-en: Chinese tech articles → English, code blocks preservedsfd-zh-to-tw: Simplified → Traditional Chinese, Taiwan terminologysfd-product: Product copy, SEO keyword structure preserved
Dry-Run Validation
# Validate without actually translating
translate --preset sfd-zh-to-en --file "./content/*.md" --dry-run
Output:
[dry-run] Would translate 12 files
[dry-run] Provider: openai / gpt-4o
[dry-run] Estimated tokens: ~45,000
[dry-run] Estimated cost: ~$0.09
Always dry-run before batch jobs. Avoid surprise API bills.
TOML Configuration File
[settings]
default_lang = "en"
concurrency = 3 # parallel file translations
retry_on_fail = 2 # retries on failure
[presets.blog]
from = "zh"
to = "en"
provider = "anthropic"
model = "claude-haiku-3-5"
prompt_template = "./prompts/blog-translation.txt"
[output]
preserve_structure = true
append_lang_suffix = true # article.md → article_en.md
Common Pitfalls
Issue 1: Code Blocks Get Mangled
Cause: Default prompt doesn't emphasize format preservation. Fix: Add to your preset prompt: "Preserve all code blocks exactly as-is. Do not translate code or technical identifiers."
Issue 2: Traditional Chinese Output Contains Simplified Characters
Fix: Explicitly add to prompt: "Use Traditional Chinese (Taiwan standard). Do not use Simplified Chinese characters or Mainland China terminology."
Issue 3: Batch Job Stops Mid-Way
Cause: API rate limiting. Fix: Lower concurrency from default 5 to 2, add retry_on_fail = 3 in config.toml.
Skill Combinations
- translate-cli + summarize: Summarize long articles first, then translate summaries — 80% cost reduction
- translate-cli + humanizer: Run translated content through humanizer to remove AI flavor before publishing
- translate-cli + smart-web-scraper: Scrape foreign-language pages → translate → store as Chinese knowledge base
SFD Lab Note
We use translate-cli for three things: ① Daily trilingual publishing on smallfiredragon.com (zh → en + zh-TW); ② Content processing by our 小春蚕 agent for BACAKU (Japanese/English → Chinese); ③ Security document analysis where 小猎鹰 needs English audit reports translated before review.
Over a month, this skill saves roughly 30 minutes of manual translation daily. For any content-driven project, this is a permanent install.