# gt: General Translation CLI tool: gt generate
URL: https://generaltranslation.com/ja/docs/cli/reference/commands/generate.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: General Translation プロジェクト用のソーステンプレートを生成します。`gt generate` コマンドの API リファレンスです。

[`translate`](/docs/cli/reference/commands/translate) コマンドと同じ形式で、デフォルトロケールとターゲットロケール向けのソーステンプレートファイルを生成します。General Translation API を介さずに自分で翻訳を管理する場合に使用し、生成した結果は[ローカル翻訳](/docs/react/guides/storing-translations)として提供できます。

*注: フレームワークおよびインラインライブラリ (`gt-next`、`gt-react`、`gt-react-native`、`gt-tanstack-start`、`gt-node`、`gt-flask`、`gt-fastapi`) で利用できます。ベース (非フレームワーク) プロジェクトでは登録されません。General Translation API を使用する場合は、代わりに [`gt translate`](/docs/cli/reference/commands/translate) を使用してください。*

まずプロジェクトを設定してから、テンプレートを生成してください。

```bash
npx gt configure
npx gt generate
```

## 仕組み [#how-it-works]

1. `gt.config.json` を読み取り、デフォルトロケールとターゲットロケールを特定します。
2. ソースコードをスキャンしてインラインコンテンツ ([`<T>`](/docs/react/reference/components/t) コンポーネントと [`useGT`](/docs/react/reference/hooks/use-gt) の呼び出し) を検出し、[`gt translate`](/docs/cli/reference/commands/translate) がコンテンツを収集するのと同様に、dictionary も含めます。
3. General Translation API を呼び出すことなく、[`translate`](/docs/cli/reference/commands/translate) が使用する形式で、各ロケール用のソーステンプレートファイルを書き出します。

## フラグ [#flags]

`generate` は [`gt translate`](/docs/cli/reference/commands/translate#flags) と同じフラグを受け付けます。ここでは、その中でも特によく使われるものを示します。完全な一覧は、上記リンク先のリファレンスを参照してください。

| パラメータ                           | 説明                                                                                                              | 型          | 任意 | デフォルト                                 |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------- | ---------- | -- | ------------------------------------- |
| `--src <paths...>`              | ソースファイルのグロブパターン。                                                                                                | `string[]` | はい | `src`、`app`、`pages`、`components` のグロブ |
| `--dictionary <path>`           | dictionary ファイルへのパス。                                                                                            | `string`   | はい | —                                     |
| `--tsconfig, --jsconfig <path>` | TS または JS の設定ファイルへのパス。                                                                                          | `string`   | はい | 自動検出                                  |
| `--inline`                      | [`<T>`](/docs/react/reference/components/t) や [`useGT`](/docs/react/reference/hooks/use-gt) などのインラインコンテンツを含めます。 | `boolean`  | はい | `true`                                |
| `--default-locale <locale>`     | プロジェクトのソースロケール。                                                                                                 | `string`   | はい | `en`                                  |
| `--ignore-errors`               | インラインコンテンツのスキャン中に見つかったエラーを無視します。                                                                                | `boolean`  | はい | `false`                               |

## 例 [#example]

```bash
# 設定済みのロケール用にtemplatesを生成する
npx gt generate

# カスタムのsourceロケールから生成し、スキャンエラーを無視する
npx gt generate --default-locale en-US --ignore-errors
```

## その他の注意事項 [#notes]

テンプレートファイルを生成したら、[ローカル翻訳](/docs/react/guides/storing-translations)としてユーザーに提供してください。ソースコンテンツが変更されるたびに、`generate` を再実行してください。

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
