purge 命令可根据指定条件从目标文件中删除翻译,包括 bucket 类型、文件模式、键或 locale。它还会同步更新 i18n.lock 文件,准确反映删除结果。
用法#
bash
npx lingo.dev@latest purge [options]选项#
| 选项 | 说明 | 示例 |
|---|---|---|
--bucket <type> | 删除指定 bucket 中的翻译。可重复使用。 | --bucket json |
--file <pattern> | 删除文件路径匹配 glob 模式的翻译。 | --file src/**/*.json |
--key <key> | 删除指定的翻译键。支持 glob 模式。 | --key app.title |
--locale <code> | 删除指定 locale 的翻译。可重复使用。 | --locale fr --locale de |
--yes-really | 跳过交互式确认提示。 | --yes-really |
示例#
删除指定键#
bash
npx lingo.dev@latest purge --key app.title从所有目标文件和 lockfile 中删除 app.title。
删除某个 bucket 中的全部翻译#
bash
npx lingo.dev@latest purge --bucket json删除指定 locale 的翻译#
bash
npx lingo.dev@latest purge --locale fr --locale de按文件模式删除#
bash
npx lingo.dev@latest purge --file src/**/*.json跳过确认#
bash
npx lingo.dev@latest purge --key obsolete.key --yes-reallyPurge + Run 工作流#
如需更高效地进行 retranslation,请先执行 purge,再在不使用 --force 的情况下运行。这样可以充分利用 CLI 的缓存机制:
bash
npx lingo.dev@latest purge --key welcome.title
npx lingo.dev@latest run这种方式比 run --force 更高效,因为它只会重新翻译已删除的内容。
