# gt: General Translation CLI tool: CD での実行
URL: https://generaltranslation.com/ja/docs/cli/guides/continuous-translation/running-in-cd.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: ビルドコマンドの前に gt translate を実行し、毎回のデプロイで最新の翻訳を配信する方法。

本番環境のビルドの直前に [`npx gt translate`](/docs/cli/reference/commands/translate) を追加するのが、Vercel や Netlify をはじめ、あらゆるデプロイパイプラインで翻訳を常に最新に保つ最も簡単な方法です。

## セットアップ [#setup]

1. `gt.config.json` をコミットし、`GT_API_KEY` と `GT_PROJECT_ID` をホスティングサービスまたは CD プロバイダーのシークレット環境変数に追加します ([共通の要件](/docs/cli/guides/continuous-translation#credentials)を参照) 。
2. ビルドスクリプトの先頭に [`npx gt translate`](/docs/cli/reference/commands/translate) を追加します：

```json title="package.json"
{
  "scripts": {
    "translate": "npx gt translate",
    "build": "npm run translate && <your build command>"
  }
}
```

デプロイパイプラインで npm スクリプトを使わずに各ステップを直接実行している場合は、ビルドステップの直前に [`npx gt translate`](/docs/cli/reference/commands/translate) を実行してください。

<Callout type="info">
  **既存のスタンドアロン翻訳：** 保持したい翻訳済みの JSON、YAML、MDX ファイルがすでにリポジトリにある場合は、自動ビルドを有効にする前に、ローカルで [`npx gt upload`](/docs/cli/reference/commands/upload) を一度実行してください。
</Callout>

## オプションとガードレール [#guardrails]

* **請求上限でビルドを失敗させない:** 組織が **利用上限** に達した場合、またはクレジットを使い切った場合、[`gt translate`](/docs/cli/reference/commands/translate) は新しい作業をエンキューする時点で失敗します。[`gt download`](/docs/cli/reference/commands/download) は請求情報による制限を受けないため、これにフォールバックすれば、変更されていない原文ファイルについては完了した翻訳をダウンロードできます(スキップされるのは、翻訳できなかった変更済みファイルのみです):

  ```bash
  npx gt translate || npx gt download
  ```

  *注: インラインコンテンツを含むフレームワークアプリで `stageTranslations` が無効の場合、[`omitConfigIds`](/docs/cli/reference/config#omit-config-ids) が `true` でない限り、[`gt download`](/docs/cli/reference/commands/download) を使うには `gt.config.json` に以前の `_versionId` が記録されている必要があります。*

* **`--force` は避ける:** `--force` はすべてを再翻訳して手動での編集を上書きし、実行のたびに課金が発生します。

* **ローカルでの編集を同期する:** チームがコミット済みの翻訳ファイルを直接編集している場合は、`--save-local` を指定するか、[`options.saveLocal`](/docs/cli/reference/config#save-local) を `true` に設定してください。

* **ブランチ、タグ、CDN:** フィーチャーブランチを分離するには `--enable-branching` を指定します([ブランチごとの翻訳の追跡](/docs/cli/guides/branching))。git コミットで実行にタグ付けするには `--tag` を、PR チェックでは `--dry-run` を使用します。また、**プロジェクト &gt; 設定** で **CDN** を有効にした後は `--publish` を使用できます。

* **適用済みの用語集の更新:** 出力を gitignore している場合は、**プロジェクト &gt; Context &gt; Apply** を実行した後のクリーンビルドで更新が自動的に取り込まれます。翻訳と `gt-lock.json` をコミットしている場合は、[`npx gt translate --force-download`](/docs/cli/reference/commands/translate) を実行して、翻訳元が変更されていないファイルを上書きしてください。

## Next steps

- /docs/cli/guides/continuous-translation/using-github-actions
- /docs/cli/guides/continuous-translation/staging-in-ci
- /docs/cli/guides/continuous-translation/splitting-ci-stages
- /docs/cli/guides/branching

## Sitemap

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