Types

GTConstructorParams

GT クラスのコンストラクター引数用の TypeScript インターフェース

概要

GTConstructorParams は、GT クラスの初期化に使用する設定 options を定義します。

interface GTConstructorParams {
  apiKey?: string;
  devApiKey?: string;
  sourceLocale?: string;
  targetLocale?: string;
  locales?: string[];
  projectId?: string;
  baseUrl?: string;
  customMapping?: CustomMapping;
}

すべてのプロパティは省略可能です。指定がない場合、コンストラクタは環境変数から GT_API_KEYGT_DEV_API_KEYGT_PROJECT_ID を読み込みます。

プロパティ

プロパティ説明
apiKey?string本番環境のAPIキー
devApiKey?string開発環境のAPIキー
sourceLocale?string既定のsourceLocale
targetLocale?string既定のtargetLocale
locales?string[]対応ロケールコード
projectId?stringプロジェクト識別子
baseUrl?stringカスタムAPIエンドポイント
customMapping?CustomMappingカスタムロケールマッピング

基本的なセットアップ

const gt = new GT({
  apiKey: 'your-api-key',
  sourceLocale: 'en',
  targetLocale: 'es',
  locales: ['en', 'es', 'fr']
});

環境変数を使う場合

const gt = new GT({
  sourceLocale: 'en',
  targetLocale: 'es'
});
// 環境変数の GT_API_KEY と GT_PROJECT_ID を使用します

関連する型

このガイドはいかがですか?