# gt: General Translation CLI tool: 翻译 CLI URL: https://generaltranslation.com/zh/docs/cli.mdx --- title: 翻译 CLI description: 使用 General Translation CLI 工具设置并翻译项目 --- ## 概述 General Translation CLI 工具 (`gt`) 可让你设置国际化,并将项目自动翻译成任意一种[受支持的语言](/docs/platform/supported-locales)。 它可与 [`gt-next`](/docs/next)、[`gt-react`](/docs/react)、[`gt-react-native`](/docs/react-native) 以及 `next-intl` 和 `i18next` 等第三方 i18n 库配合使用。你也可以用它来翻译独立文件 (JSON、MDX、HTML 等) 。 ## 快速入门 ### 1. 设置项目 ```bash npx gt@latest ``` 这会运行设置向导,它将: * 安装必要的依赖项 (例如 `gt-next` 或 `gt-react`) * 配置你的框架 (如 Next.js plugin、React Provider 等) * 创建包含你的区域设置和文件配置的 `gt.config.json` * 生成 API 凭据 ### 2. translate ```bash npx gt translate ``` 此命令会使用 General Translation API 翻译你的项目。请在面向生产环境进行 build **之前**,在 CI/CD 处理流水线中运行它。 **注意:** `translate` 命令需要生产环境 API 密钥。设置向导可以为你生成一个,或者你也可以在 [generaltranslation.com](https://generaltranslation.com) 获取。 就是这样——只需两条命令,即可将单语言项目转换为完整翻译的项目。 ## 命令 | 命令 | 说明 | | ------------------------------------------- | -------------------------------- | | [`npx gt@latest`](/docs/cli/init) | 运行设置向导。安装依赖项、配置项目并生成凭证。 | | [`npx gt translate`](/docs/cli/translate) | 通过 GT API 翻译你的项目。 | | [`npx gt configure`](/docs/cli/configure) | 更新项目的 GT 配置 (`gt.config.json`) 。 | | [`npx gt auth`](/docs/cli/auth) | 生成或刷新 API 凭证。 | | [`npx gt generate`](/docs/cli/generate) | 生成一个可供独立使用的译文数据 JSON 文件。 | | [`npx gt upload`](/docs/cli/upload) | 将源文件和译文上传到 GT 平台。 | | [`npx gt enqueue`](/docs/cli/enqueue) | 将文件加入翻译队列,但不下载结果。 | | [`npx gt download`](/docs/cli/download) | 下载此前已加入队列或已进入待审核状态的译文。 | | [`npx gt stage`](/docs/cli/stage) | 在发布前将译文置为待人工审核状态。 | | [`npx gt save-local`](/docs/cli/save-local) | 将本地译文修改保存到 GT 平台。 | ## 指南 | 指南 | 说明 | | --------------------------- | ------------------- | | [分支管理](/docs/cli/branching) | 针对不同的 Git 分支分别跟踪翻译。 | | [FAQ](/docs/cli/faqs) | 关于 CLI 工具的常见问题。 | ## 支持的格式 CLI 可翻译多种格式的文件: [GT](/docs/cli/formats/gt) · [JSON](/docs/cli/formats/json) · [MDX](/docs/cli/formats/mdx) · [TypeScript/JavaScript](/docs/cli/formats/ts) · [YAML](/docs/cli/formats/yaml) · [PO/POT](/docs/cli/formats/po) · [HTML](/docs/cli/formats/html) · [纯文本](/docs/cli/formats/txt)