# gt: General Translation CLI tool: 設定 URL: https://generaltranslation.com/ja/docs/cli/reference/config.mdx --- title: "設定" description: "`gt.config.json` ファイルで General Translation CLI を設定します。`gt.config.json` の API リファレンス。" --- `gt.config.json` ファイルでは、CLI が翻訳する対象と、結果の保存先を設定します。プロジェクトのルートに配置してください。[`gt init`](/docs/cli/reference/commands/init) または [`gt configure`](/docs/cli/reference/commands/configure) で作成するか、手動で記述できます。 *注: エディタでの検証と自動補完のために、`$schema` キーで [JSON Schema](https://assets.gtx.dev/config-schema.json) を追加してください。* ## オプション [#options] | オプション | 説明 | 型 | 任意 | デフォルト | | ------------------------------------ | -------------------------------------- | ---------- | -- | ----------------- | | [`defaultLocale`](#default-locale) | ソースコンテンツが記述されているロケール。 | `string` | はい | `en` | | [`locales`](#locales) | 翻訳先のターゲットロケール。 | `string[]` | はい | — | | [`files`](#files) | 翻訳するファイルと保存先。 | `object` | はい | — | | [`publish`](#publish) | 翻訳済みファイルを CDN に公開します。 | `boolean` | はい | `false` | | [`stageTranslations`](#stage) | 翻訳を配信する前に人手によるレビューを必須にします。 | `boolean` | はい | `false` | | [`requiresReview`](#requires-review) | すべての翻訳済みファイルに適用されるデフォルトのレビュー制御ポリシー。 | `boolean` | はい | `false` | | [`src`](#src) | インラインコンテンツを検出するために走査するソースファイルのグロブパターン。 | `string[]` | はい | [`src`](#src) を参照 | | [`dictionary`](#dictionary) | dictionary ファイルへのパス。 | `string` | はい | — | | [`branchOptions`](#branch-options) | ブランチベースの翻訳追跡設定。 | `object` | はい | — | | [`customMapping`](#custom-mapping) | ロケールのエイリアスとプロパティのオーバーライド。 | `object` | はい | — | ## `defaultLocale` [#default-locale] **型** `string` · **任意** · **デフォルト** `en` ソースコンテンツが記述されているロケールです。CLI はこのロケールを翻訳元として使用し、`gt-next` または `gt-react` を使用する場合のフォールバック ロケールにもなります。 ```json title="gt.config.json" { "defaultLocale": "en" } ``` ## `locales` [#locales] **型** `string[]` · **任意** · **デフォルト** — 翻訳先のターゲットロケールを指定します。使用可能なコードについては、[サポートされているロケール](/docs/platform/dashboard/reference/supported-locales)を参照してください。`gt-next` または `gt-react` を使用する場合、これらはアプリがサポートするロケールにもなります。 ```json title="gt.config.json" { "locales": ["fr", "es", "ja"] } ``` ## `files` [#files] **型** `object` · **任意** · **デフォルト** — 翻訳対象のファイル形式ごとに 1 つのキーを持つオブジェクトです。各形式は設定オブジェクトに対応します。形式ごとの詳細については、[ファイル形式](/docs/cli/reference/formats/gt-jsx-files) を参照してください。 ### サポートされているファイルタイプ | キー | ファイルタイプ | 参照 | | ------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------- | | `gt` | `gt-next`、`gt-react`、`gt-react-native` 用の General Translation ファイル。 | [GT](/docs/cli/reference/formats/gt-jsx-files) | | `json` | JSON ファイル。 | [JSON](/docs/cli/reference/formats/json-files) | | `yaml` | YAML ファイル (`.yaml` および `.yml`) 。 | [YAML](/docs/cli/reference/formats/yaml-files) | | `pot` | PO/POT gettext ファイル。 | [PO / POT](/docs/cli/reference/formats/po-pot-files) | | `mdx` | MDX ファイル。 | [MDX and Markdown](/docs/cli/reference/formats/mdx-md-files) | | `md` | Markdown ファイル。 | [MDX and Markdown](/docs/cli/reference/formats/mdx-md-files) | | `ts` | TypeScript ファイル。 | [TypeScript and JavaScript](/docs/cli/reference/formats/ts-js-files) | | `js` | JavaScript ファイル。 | [TypeScript and JavaScript](/docs/cli/reference/formats/ts-js-files) | | `html` | HTML ファイル。 | [HTML](/docs/cli/reference/formats/html-files) | | `txt` | プレーンテキスト ファイル。 | [Plain text](/docs/cli/reference/formats/plain-text-files) | | `twilioContentJson` | Twilio Content JSON テンプレート。 | — | ### ファイルタイプのキー 各ファイルタイプでは、次のキーを使用できます。 * `include` — 翻訳対象のファイルに一致する glob パターンの配列です。`[locale]` プレースホルダーを使用します。CLI はこれを `defaultLocale` に置き換えてソースファイルを見つけ、各ターゲットコードに置き換えて翻訳を保存します。`gt` を除くすべてのタイプで必須です。 * `exclude` — スキップする glob パターンの配列です。ここでは `[locale]` プレースホルダーは任意です。すべてのロケールにまたがってパスを除外するには `[locales]` を使用します。 * `transform` — 出力ファイル名を変換します。`*` ワイルドカードを含む文字列は拡張子を変換します (例: `*.[locale].json`) 。`match` と `replace` を持つオブジェクトでは、正規表現のキャプチャグループと `{locale}` プレースホルダーを使用できます。 * `transformationFormat` — source とは異なる形式で翻訳済みファイルを出力します。たとえば、`"transformationFormat": "PO"` を指定した `pot` source からは `.po` ファイルが生成されます。 * `requiresReview` — 翻訳済みファイルを人手によるレビュー後にのみ公開されるようにします。`true`/`false`、または `include` と `exclude` の glob 配列を持つオブジェクトを指定できます。この場合、`exclude` が優先されます。 * `output` — `gt` ファイル専用で、`public/i18n/[locale].json` のように `[locale]` プレースホルダーを含むローカルの保存パスです。 * `parsingFlags` — `gt` ファイル専用で、インラインコンテンツの解析を制御するフラグです。[`autoderive`](/docs/cli/guides/using-autoderive) と [自動 JSX インジェクション](/docs/cli/guides/using-auto-jsx) を参照してください。 ```json title="gt.config.json" { "files": { "gt": { "output": "public/i18n/[locale].json" }, "mdx": { "include": ["content/docs/[locale]/**/*.mdx"], "transform": "*.[locale].mdx" }, "json": { "include": ["resources/[locale]/**/*.json"], "exclude": ["resources/[locale]/exclude/**/*.json"] } } } ``` ## `publish` [#publish] **型** `boolean` · **任意** · **デフォルト** `false` `true` の場合、[`translate`](/docs/cli/reference/commands/translate)、`upload`、または `save-local` の実行後に、翻訳済みファイルが General Translation CDN に公開されます。ファイル単位およびコマンド単位での制御については、[CDN 公開](#cdn-publishing) を参照してください。 ```json title="gt.config.json" { "publish": true } ``` ## `stageTranslations` [#stage] **型** `boolean` · **任意** · **デフォルト** `false` `true` の場合、翻訳は配信前に人手によるレビューが必要になります。CLI は、初めて [`gt stage`](/docs/cli/reference/commands/stage) を実行した際に、これを自動的に設定します。有効にすると、`translate` は `gt stage` でステージしたバージョンの翻訳のみをダウンロードします。何もステージしていない場合、ダウンロードするものはありません。 ## `requiresReview` [#requires-review] **型** `boolean` · **任意** · **デフォルト** `false` レビュー必須設定のプロジェクト全体のデフォルト値です。`true` の場合、翻訳済みの成果物は、クライアントが使用する前に承認が必要になります。指定できる値は boolean のみです。glob 単位の overrides には、ファイルごとの [`files..requiresReview`](#files) キー (boolean または `{ include, exclude }` の glob を受け付けます) を使用してください。ファイルごとのポリシーが優先され、`include` と `exclude` のどちらの glob にも一致しないファイルには、このトップレベルのデフォルト値が適用されます。 ```json title="gt.config.json" { "requiresReview": true } ``` ## `src` [#src] **型** `string[]` · **省略可能** · **デフォルト** `src`、`app`、`pages`、`components` の glob `gt-next`、`gt-react`、または `gt-react-native` を使用する際に、インラインコンテンツを検出するためにスキャンされるソースファイルの glob パターンの配列です。 ```json title="gt.config.json" { "src": [ "src/**/*.{js,jsx,ts,tsx}", "app/**/*.{js,jsx,ts,tsx}", "pages/**/*.{js,jsx,ts,tsx}", "components/**/*.{js,jsx,ts,tsx}" ] } ``` ## `dictionary` [#dictionary] **型** `string` · **任意** · **デフォルト** — dictionary ファイルへの相対パスを指定します。省略した場合、CLI は `./src` と `./` 内で `dictionary.[json|ts|js]` を探します。 ```json title="gt.config.json" { "dictionary": "./dictionary.json" } ``` ## `branchOptions` [#branch-options] **型** `object` · **任意** · **デフォルト** — ブランチごとの翻訳追跡を設定します。[ブランチごとの翻訳追跡](/docs/cli/guides/branching)を参照してください。CLI フラグはこれらの値より優先されます。 | プロパティ | 説明 | 型 | 任意 | デフォルト | | -------------------- | ------------------------------- | --------- | -- | -------- | | `enabled` | プロジェクトで Branching を有効にします。 | `boolean` | はい | `false` | | `currentBranch` | 検出されたブランチ名を上書きします。 | `string` | はい | — | | `autoDetectBranches` | 送信元ブランチとチェックアウト中のブランチの関係を検出します。 | `boolean` | はい | `true` | | `remoteName` | ブランチ検出に使用する Git リモート名です。 | `string` | はい | `origin` | ```json title="gt.config.json" { "branchOptions": { "enabled": true, "currentBranch": "my-feature-branch", "autoDetectBranches": true, "remoteName": "origin" } } ``` ## `customMapping` [#custom-mapping] **型** `object` · **任意** · **デフォルト** — ロケールを別のコードにエイリアスし、必要に応じてそのプロパティを上書きします。たとえば、`cn` を公式コード `zh` のエイリアスにできます。 ```json title="gt.config.json" { "customMapping": { "cn": { "code": "zh", "name": "Mandarin" } } } ``` ## CDN 公開 [#cdn-publishing] デフォルトでは、CLI は CDN に公開しません。プロジェクトの設定で CDN を有効にすると、公開をグローバル、ファイルごと、またはコマンドごとに制御できます。 * **グローバル:** トップレベルの [`publish`](#publish) を `true` に設定するか、`translate`、`upload`、または `save-local` に `--publish` を渡します。 * **GT ファイルのみ:** `files.gt` の下で `publish: true` を設定します。 * **ファイルごと:** `include` 配列で、グロブ文字列を `pattern` と `publish` を持つオブジェクトに置き換えることで、一致したファイルを公開対象に含めるか除外するかを指定します。 ```json title="gt.config.json" { "files": { "json": { "include": [ { "pattern": "locales/[locale]/*.json", "publish": true }, { "pattern": "locales/[locale]/internal/**/*.json", "publish": false } ] } } } ``` 任意のファイルについて、CLI は公開するかどうかを次の順序で判断します。まず明示的な `"publish": false` によるオプトアウト、次に明示的な `"publish": true` によるオプトイン、最後にグローバルの `publish` 設定です。どのレベルにも公開設定が存在しない場合、公開ステップはスキップされます。 ## 設定例 [#example] ```json title="gt.config.json" { "$schema": "https://assets.gtx.dev/config-schema.json", "defaultLocale": "en", "locales": ["fr", "es"], "files": { "gt": { "output": "public/i18n/[locale].json" }, "mdx": { "include": ["content/docs/[locale]/**/*.mdx"], "transform": "*.[locale].mdx" }, "json": { "include": ["resources/[locale]/**/*.json"], "exclude": ["resources/[locale]/exclude/**/*.json"] } } } ``` この設定では、[`gt translate`](/docs/cli/reference/commands/translate) を1回実行するだけで、`content/docs/en` 配下の MDX ファイル (`.fr.mdx` と `.es.mdx` として `content/docs/fr` および `content/docs/es` に保存) 、`resources/en` 配下の JSON ファイル (`resources/en/exclude` を除く) 、さらにインラインの [``](/docs/react/reference/components/t) コンポーネントと dictionary エントリが翻訳されます。GT の翻訳は `public/i18n/fr.json` と `public/i18n/es.json` に保存されます。