mcpField
C
crowdin-context-cli

crowdin-context-cli

github.com/crowdin开发9112 次安装6 天前更新
代码仓库

关于 crowdin-context-cli

Crowdin Context CLI 用于下载、编辑并上传字符串的 AI 上下文,也可查看覆盖统计或清除 AI 生成的上下文。它面向需要在 Crowdin 项目中批量维护翻译上下文的本地化工作流。

主要功能

  1. 01按文件、标签或分支筛选字符串
  2. 02以 JSONL 下载和上传上下文
  3. 03查看上下文覆盖统计
  4. 04重置 AI 上下文并保留人工内容
  5. 05支持 dryrun 安全预览

适用场景

  1. 01导出字符串供 AI Agent 补充上下文
  2. 02按项目分支检查上下文覆盖情况
  3. 03上传已编辑的 AI 上下文
  4. 04重新生成前清除旧 AI 上下文

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/crowdin/skills --skill crowdin-context-cli

安装后在 Claude Code 中输入/crowdin-context-cli确认已加载。

详细介绍

Crowdin 上下文 CLI

使用 Crowdin CLI 下载和上传上下文。默认从 crowdin.yml 读取配置;如有需要,可使用 -c, --config=<path> 覆盖。

crowdin context <command> [options]

context download

将字符串上下文下载到单独的文件,以便通过 AI Agent 补充内容。

crowdin context download [CONFIG OPTIONS] [OPTIONS]
  • --to=<path> — 下载上下文的文件路径。默认值:crowdin-context.jsonl
  • -f, --file=<glob> — 按 Crowdin 文件路径(glob)筛选字符串。可指定多个路径
  • --label=<label> — 按标签筛选字符串。可指定多个标签
  • -b, --branch=<name> — 按分支名称筛选
  • --croql=<expr> — CroQL 表达式(不能与其他筛选选项组合使用)
  • --since=<YYYY-MM-DD> — 仅包含在此日期之后创建的字符串
  • --status=<value> — 字符串已有的上下文类型:empty(没有任何类型的上下文)、manual(有源上下文,没有 AI 上下文)、ai(已写入 AI 上下文)。见下文——此选项并非用于筛选“仍需要上下文”的字符串

配置选项(不使用配置文件时):-T, --token、-i, --project-id、--base-url、--base-path。使用 -c, --config=<path> 覆盖配置文件(默认值:crowdin.yml 或 crowdin.yaml)。

根据源格式的不同,选择哪些需要 AI 上下文的字符串取决于 --status,因此建议省略此选项。 有些格式会将源引用带入 Crowdin,例如 PO 的 #: 行,这会使每个字符串都带有手动上下文,因此 empty 不会匹配任何内容,而 manual 会匹配所有内容;完全不携带上下文的格式则恰好相反。不指定 --status 时,一次下载即可涵盖这两种情况,且不会增加额外开销:context upload 只会回写实际填入了 ai_context 的记录。

context upload

上传字符串上下文。仅支持之前通过 context download 下载的文件。

crowdin context upload [CONFIG OPTIONS] [OPTIONS]
  • --from=<path> — 上传上下文的文件路径。默认值:crowdin-context.jsonl
  • --overwrite — 同时更新 ai_context 为空的字符串(移除其 AI 部分)。默认值:false
  • --dryrun — 打印命令输出但不执行

context status

显示上下文覆盖情况统计——有手动上下文、AI 上下文或无上下文的字符串数量。

crowdin context status [CONFIG OPTIONS] [OPTIONS]
  • -f, --file=<glob> — 按 Crowdin 文件路径(glob)筛选字符串。可指定多个路径
  • --label=<label> — 按标签筛选字符串。可指定多个标签
  • -b, --branch=<name> — 按分支名称筛选
  • --croql=<expr> — CroQL 表达式(不能与其他筛选选项组合使用)
  • --since=<YYYY-MM-DD> — 仅包含在此日期之后创建的字符串
  • --by-file — 按文件细分统计数据

context reset

移除字符串中由 AI 生成的上下文;手动编写的上下文会保留。

crowdin context reset [CONFIG OPTIONS] [OPTIONS]
  • -f, --file=<glob> — 仅重置匹配文件路径中的字符串。可指定多个路径
  • --label=<label> — 仅重置带有匹配标签的字符串。可指定多个标签
  • -b, --branch=<name> — 仅重置来自匹配分支的字符串
  • --croql=<expr> — 仅重置匹配 CroQL 表达式的字符串(不能与其他筛选选项组合使用)
  • --since=<YYYY-MM-DD> — 仅重置在此日期之后创建的字符串
  • --dryrun — 打印命令输出但不执行
  • --all — 未指定筛选条件时必须使用的安全标志

JSONL 格式

每行一个 JSON 对象。字段:

  • id — Crowdin 中的字符串 ID
  • key — 字符串键
  • text — 源文本
  • file — Crowdin 文件路径
  • context — 现有源上下文
  • ai_context — 要设置的 AI 上下文(上传前请编辑此字段)

示例行:

{"file":"/src/locales/en.po","ai_context":"","context":"#: src/App.tsx:54","id":3125833,"text":"Click on the Vite and React logos to learn more","key":"Click on the Vite and React logos to learn more"}

典型工作流

  1. 检查覆盖情况(可选):crowdin context status — 查看人工、AI 和无上下文的分布。在为下一步选择 --status 筛选条件前先阅读结果,也可以跳过筛选并获取全部内容。
  2. 下载:crowdin context download(默认写入 crowdin-context.jsonl),或使用 crowdin context download --to=path/to/file.jsonl
  3. 编辑文件 — 为每个字符串填写 ai_context(可借助 context-extraction)。
  4. 上传:crowdin context upload(默认读取 crowdin-context.jsonl),或使用 crowdin context upload --from=path/to/file.jsonl

若之后要丢弃 AI 生成的上下文(例如从头重新运行增强流程前),请使用带筛选条件的 crowdin context reset,或使用 crowdin context reset --all。

评论

支持 Markdown