@rongyan/x-tweet-translator
v0.1.3
Published
Install the x-tweet-translator skill for Codex, Claude Code, and OpenCode.
Maintainers
Readme
X推文翻译器
自动翻译 X(Twitter) 推文采集数据中的非中文内容。JSON 文件建议通过 extract -> check -> apply 的方式安全写回,避免破坏结构。
安装
使用 npx 安装到指定 AGENT:
npx @rongyan/x-tweet-translator install --target codexnpx @rongyan/x-tweet-translator install --target claude-codenpx @rongyan/x-tweet-translator install --target opencode也支持直接省略 install:
npx @rongyan/x-tweet-translator --target codex默认安装位置:
codex→${CODEX_HOME:-~/.codex}/skills/x-tweet-translatorclaude-code→~/.claude/skills/x-tweet-translatoropencode→~/.config/opencode/skills/x-tweet-translator
需要覆盖已有安装时,可加 --force:
npx @rongyan/x-tweet-translator install --target claude-code --force如果只想预览写入位置,可加 --dry-run:
npx @rongyan/x-tweet-translator install --target opencode --dry-run功能特点
- 支持 JSON 和 Markdown 两种格式
- 大模型直接翻译,无需外部 API 或脚本
- 自动检测中文内容,跳过已有中文的字段
- 支持外链文章的递归翻译
- 自动跳过 URL 链接,保留 @用户名、#标签、emoji
- 原始文件不变,翻译结果写入
-cn后缀的新文件
使用方法
直接告诉 Claude/opencode 需要翻译的文件或目录:
请翻译 /path/to/tweets.json请翻译 /path/to/tweets/ 目录下所有的 JSON 文件翻译 /path/to/x-collection-2026-04-25.md如果是手动运行 JSON 脚本,推荐顺序是:
node <skill-dir>/scripts/translate-json.js extract /path/to/input.json /tmp/plan.json
# 字段多时用 pending / fill 分批填入 translation
node <skill-dir>/scripts/translate-json.js pending /tmp/plan.json 8 > /tmp/pending.json
node <skill-dir>/scripts/translate-json.js fill /tmp/plan.json /tmp/translations.json
node <skill-dir>/scripts/translate-json.js check /path/to/input.json /tmp/plan.json
node <skill-dir>/scripts/translate-json.js apply /path/to/input.json /tmp/plan.json常见 skill-dir:
- Codex:
${CODEX_HOME:-~/.codex}/skills/x-tweet-translator - Claude Code:
~/.claude/skills/x-tweet-translator - OpenCode:
~/.config/opencode/skills/x-tweet-translator
输出规则
| 原文件 | 翻译输出 |
|--------|----------|
| 2026-04-25-01.json | 2026-04-25-01-cn.json |
| 2026-04-25-01.md | 2026-04-25-01-cn.md |
| articles-data/article.json | articles-data/article-cn.json |
| articles/article.md | articles/article-cn.md |
翻译字段
JSON 文件
tweets[].texttweets[].article.titletweets[].article.previewText- 外链文章:
title、previewText、plainText、contentState.blocks[].text
Markdown 文件
- 非中文的正文段落
- 外链文章文件中的非中文段落
翻译规则
- 已含中文的字段 → 跳过
- 纯 URL → 跳过
- @用户名、#标签、数字、emoji → 保留原样
- Markdown 结构、链接 → 保留原样
