删除翻译

更新时间:2个季度前 · 预计阅读 1 分钟

已弃用

这些文档介绍的是旧版 CLI(v0)。当前 CLI 版本为 v1。 查看当前 CLI 文档

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-really

Purge + Run 工作流#

如需更高效地进行 retranslation,请先执行 purge,再在不使用 --force 的情况下运行。这样可以充分利用 CLI 的缓存机制:

bash
npx lingo.dev@latest purge --key welcome.title
npx lingo.dev@latest run

这种方式比 run --force 更高效,因为它只会重新翻译已删除的内容。

下一步#