# gt: General Translation CLI tool: GT
URL: https://generaltranslation.com/ja/docs/cli/reference/formats/gt-jsx-files.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: General Translation を使って gt-next、gt-react、gt-react-native のプロジェクトを翻訳します。gt ファイル形式の API リファレンス。

`gt` ファイル形式には、[`gt-react`、`gt-next`、または `gt-react-native`](/docs/react/overview) を使用するプロジェクトの翻訳が格納されます。[`gt translate`](/docs/cli/reference/commands/translate) を実行すると、CLI はソースコード内のインラインコンテンツ ([`<T>`](/docs/react/reference/components/t) コンポーネントや [`useGT`](/docs/react/reference/hooks/use-gt) の呼び出しなど) と辞書をスキャンし、その結果をこの形式で書き込みます。

## 設定 [#config]

`files` の下に `gt` エントリを追加します。ローカルに翻訳を保存するために、`[locale]` プレースホルダーを含む `output` パスを指定できます。

```json title="gt.config.json"
{
  "defaultLocale": "en",
  "locales": ["fr", "es"],
  "files": {
    "gt": {
      "output": "public/i18n/[locale].json"
    }
  }
}
```

これにより、フランス語とスペイン語の翻訳は `public/i18n/fr.json` および `public/i18n/es.json` に保存され、[`loadTranslations`](/docs/react/reference/functions/load-translations) で読み込めます。

## 保存オプション [#storage]

* **ローカル:** `output` を設定すると、翻訳がアプリにバンドルされます。これはデフォルト設定で、この構成では CLI は CDN に公開しません。
* **CDN:** `output` を省略し、公開を有効にすると、代わりに Runtime で翻訳を読み込みます。詳しくは [CDN 公開](/docs/cli/reference/config#cdn-publishing) を参照してください。

現在、生成できる出力ファイルはロケールごとに 1 つのみです。

## インラインコンテンツの解析 [#parsing]

`gt` のエントリでは、CLI によるインラインコンテンツの解析方法を制御する `parsingFlags` オブジェクトを指定できます。すべてのフラグはデフォルトで無効です。

```json title="gt.config.json"
{
  "files": {
    "gt": {
      "parsingFlags": {
        "autoderive": true,
        "devHotReload": true,
        "enableAutoJsxInjection": true,
        "includeSourceCodeContext": true,
        "legacyGtReactImportSource": false
      }
    }
  }
}
```

* `autoderive` — [`derive()`](/docs/react/reference/functions/derive) でラップされた場合と同様に、[`t()`](/docs/react/reference/functions/t-function)、`gt()`、[`msg()`](/docs/react/reference/functions/msg) の呼び出し内の補間値と、[`<T>`](/docs/react/reference/components/t) コンポーネント内の式を解析し、取りうる値ごとに個別の翻訳エントリを生成します。`true` または `{ "jsx": true, "strings": false }` のようなオブジェクトを受け付けます。詳しくは [Auto-derive translations](/docs/cli/guides/using-autoderive) を参照してください。
* `devHotReload` — 開発中に新しいコンテンツに対する実行時翻訳を有効にします。`true` を指定すると string translation が有効になります。string と JSX の処理を個別に制御するには、`{ "strings": true, "jsx": true }` のようなオブジェクトを使用します。
* `enableAutoJsxInjection` — 翻訳対象の JSX テキストをビルド時に [`<T>`](/docs/react/reference/components/t) コンポーネントでラップするため、手動で追加する必要がなくなります。詳しくは [Automatic JSX injection](/docs/cli/guides/using-auto-jsx) を参照してください。
* `includeSourceCodeContext` — 各翻訳に追加のコンテキストとして周囲のソースコード行を含めます。非推奨のトップレベル `files.gt.includeSourceCodeContext` キーの代わりとなるものです。
* `legacyGtReactImportSource` — コンパイラによって挿入された import を `gt-react/browser` に解決するようにします。このパスを export する従来の `gt-react` バージョンでのみ有効にしてください。現在のバージョンではルートの `gt-react` import を使用します。

## Sitemap

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