# gt: General Translation CLI tool: gt stage URL: https://generaltranslation.com/zh/docs/cli/reference/commands/stage.mdx --- title: gt stage description: 提交项目进行异步翻译,并在稍后下载。gt stage 命令的 API 参考。 --- 提交项目进行异步翻译,而不会在同一次运行中下载或发布结果。当你的项目启用了人工审校,或者 Lottie 等格式无法在单次 [`gt translate`](/docs/cli/reference/commands/translate) 运行中完成时,请使用此命令。有关这两种工作流,请参阅[管理翻译](/docs/cli/guides/managing-translations)。 运行 `stage` 会在你的 `gt.config.json` 中将 `stageTranslations` 设为 `true`。启用后,如果某个版本在暂存前就运行 [`gt translate`](/docs/cli/reference/commands/translate),CLI 会报错并退出。翻译准备就绪后——如需审校,则须待其获批——运行 [`gt download`](/docs/cli/reference/commands/download)。[`gt translate`](/docs/cli/reference/commands/translate) 也可以下载之前暂存的版本。 *注意:仅限生产环境使用。需要生产环境的 `GT_API_KEY` 和 `GT_PROJECT_ID`。* ```bash npx gt stage ``` ## 工作方式 [#how-it-works] 1. 读取 `gt.config.json`,扫描框架项目中的源代码以查找内联内容,并收集文件——与 [`gt translate`](/docs/cli/reference/commands/translate) 的处理方式相同。 2. 将内容发送到 General Translation API,但不会在同一次运行中下载或发布结果。需要审校的项目会保留已完成的翻译,等待批准。 3. 在 `gt.config.json` 中设置 `stageTranslations: true`,使后续运行都必须先进行暂存。 启用 `stageTranslations` 后,如果未先暂存该版本就运行 [`translate`](/docs/cli/reference/commands/translate),CLI 会报错并退出。使用 [`gt download`](/docs/cli/reference/commands/download) 下载已完成的翻译,或者对任何先前暂存的版本使用 [`gt translate`](/docs/cli/reference/commands/translate)。 ## 标志 [#flags] `stage` 接受与 [`gt translate`](/docs/cli/reference/commands/translate#flags) 相同的标志,包括框架项目的源扫描标志。下面列出的是最常用的几个;完整列表请参阅上方链接的参考文档。 | 参数 | 说明 | 类型 | 可选 | 默认值 | | --------------------------- | --------------------------- | ---------- | -- | ---------------- | | `--api-key ` | 生产 API 密钥。 | `string` | 是 | `GT_API_KEY` | | `--project-id ` | 项目 ID。 | `string` | 是 | `GT_PROJECT_ID` | | `-c, --config ` | config file 的路径。 | `string` | 是 | `gt.config.json` | | `--locales ` | 额外的目标区域设置,会追加到配置中的 locales。 | `string[]` | 是 | — | | `--default-locale ` | 项目的源区域设置。 | `string` | 是 | `en` | | `--dry-run` | 仅解析并验证,不调用 API。 | `boolean` | 是 | `false` | | `--tag [value]` | 为此次运行添加标签;未提供值时会自动从 git 解析。 | `string` | 是 | — | | `-m, --message ` | 附加到翻译标签上的消息。 | `string` | 是 | — | ## 示例 [#example] ```bash # 暂存翻译以供人工审校 npx gt stage # 暂存并为本次运行添加标签,以便在仪表板中追踪 npx gt stage --tag v2.1.0 -m "Q3 release" # 翻译准备就绪后,下载翻译内容 npx gt download ``` ## 其他说明 [#notes] * 启用人工审校或翻译 [Lottie](/docs/cli/reference/formats/lottie-files) 等异步格式时,请使用 `stage`。 - 执行暂存会设置 [`stageTranslations`](/docs/cli/reference/config#stage) 配置键。参见[将翻译暂存以供审校](/docs/cli/guides/managing-translations#review)。