# gt: General Translation CLI tool: 生成源模板 URL: https://generaltranslation.com/zh/docs/cli/generate.mdx --- title: 生成源模板 description: 如何为项目生成源模板 --- ## 用法 ```bash npx gt generate ``` ## 概述 `gt generate` 命令会为你的项目生成默认区域设置和所有受支持区域设置的源文件。 生成的文件兼容 [`gt-next`](/docs/next)、[`gt-react`](/docs/react) 和 [`gt-react-native`](/docs/react-native) 库,且格式与 `translate` 命令使用的格式相同。 生成源文件后,你可以使用[本地翻译](/docs/next/guides/local-tx)向用户提供这些翻译。 只有在你使用自己的翻译服务时,这个命令才有用。 如果你使用的是 General Translation API,则应使用 [`translate`](/docs/cli/translate) 命令。 ## 参数 | Parameter | Description | Type | Optional | Default | | ------------------------------- | ----------------------------------- | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- | | `--src ` | 用空格分隔的 glob 模式列表,用于匹配源文件。路径应相对于根目录。 | `[string]` | `true` | `[ 'src/**/*.{js,jsx,ts,tsx}', 'app/**/*.{js,jsx,ts,tsx}', 'pages/**/*.{js,jsx,ts,tsx}', 'components/**/*.{js,jsx,ts,tsx}', ]` | | `--dictionary ` | 指定字典文件路径 | `string` | `true` | | | `--tsconfig, --jsconfig ` | 指定 TS 或 JS 配置文件路径 | `string` | `true` | | | `--inline` | 除字典外,还包含内联 `` 标签 | `boolean` | `true` | `true` | | `--default-locale ` | 项目的源区域设置 | `string` | `true` | `en` | | `--ignore-errors` | 忽略错误,并强制翻译有效内容 | `flag` | `true` | `false` | ## 设置 首先,运行 `gt configure` 命令以配置项目设置。 ```bash npx gt configure ``` 然后,运行 `gt generate` 命令,为项目生成模板文件。 ```bash npx gt generate ``` ### 配置文件 有关 `gt.config.json` 文件的更多信息,请参见[这里](/docs/cli/reference/config)。