# General Translation Platform: GTConstructorParams
URL: https://generaltranslation.com/ja/docs/platform/core/reference/types/gt-constructor-params.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: GT コンストラクタで利用できる設定オプション。GTConstructorParams 型の API リファレンス。

`GTConstructorParams` は、[`GT`](/docs/platform/core/reference/gt-class/constructor) インスタンスの API 認証情報、ロケール、エンドポイントを設定するために、General Translation の [コンストラクタ](/docs/platform/core/reference/gt-class/constructor) に渡されるオブジェクトです。

## 概要 [#overview]

すべてのプロパティは任意です。`apiKey`、`devApiKey`、`projectId` が指定されていない場合、コンストラクタはそれらの値を `GT_API_KEY`、`GT_DEV_API_KEY`、`GT_PROJECT_ID` 環境変数から読み取ります。

```typescript
type GTConstructorParams = {
  apiKey?: string;
  devApiKey?: string;
  sourceLocale?: string;
  targetLocale?: string;
  locales?: string[];
  projectId?: string;
  baseUrl?: string;
  customMapping?: CustomMapping;
};
```

## プロパティ [#properties]

| プロパティ                              | 説明                                      | 型                                                                     | 任意 | デフォルト                        |
| ---------------------------------- | --------------------------------------- | --------------------------------------------------------------------- | -- | ---------------------------- |
| [`apiKey`](#api-key)               | プロジェクトのAPIキー。                           | `string`                                                              | はい | `process.env.GT_API_KEY`     |
| [`devApiKey`](#dev-api-key)        | 代替のプロジェクトAPIキー。`apiKey` が未設定の場合に使用されます。 | `string`                                                              | はい | `process.env.GT_DEV_API_KEY` |
| [`sourceLocale`](#source-locale)   | デフォルトのソースロケール。                          | `string`                                                              | はい | —                            |
| [`targetLocale`](#target-locale)   | デフォルトの対象ロケール。                           | `string`                                                              | はい | —                            |
| [`locales`](#locales)              | サポートされているロケールコード。                       | `string[]`                                                            | はい | —                            |
| [`projectId`](#project-id)         | プロジェクト ID。                              | `string`                                                              | はい | `process.env.GT_PROJECT_ID`  |
| [`baseUrl`](#base-url)             | APIエンドポイント。                             | `string`                                                              | はい | `https://api.gtx.dev`        |
| [`customMapping`](#custom-mapping) | カスタムロケールマッピング。                          | [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) | はい | —                            |

### `apiKey` [#api-key]

**型** `string` · **任意** · **デフォルト** `process.env.GT_API_KEY`

翻訳サービス用のプロジェクト API キーです。指定がない場合は、`GT_API_KEY` 環境変数が使用されます。

### `devApiKey` [#dev-api-key]

**型** `string` · **任意** · **デフォルト** `process.env.GT_DEV_API_KEY`

`apiKey` の非推奨のエイリアスで、`apiKey` が未設定の場合に使用されます。未指定の場合は `GT_DEV_API_KEY` が使用されます。なお、これによって環境ごとに異なるキーの種類が選択されるわけではありません。

### `sourceLocale` [#source-locale]

**型** `string` · **任意**

翻訳のデフォルトのソースロケール。設定した表記はそのまま保持され、有効なカスタムマッピングに基づいて検証されます。

### `targetLocale` [#target-locale]

**型** `string` · **任意**

翻訳のデフォルトのターゲットロケールです。設定した表記はそのまま保持され、適用されるカスタムマッピングに基づいて検証されます。

### `locales` [#locales]

**型** `string[]` · **任意**

サポートされているロケール識別子の配列。表記やカスタムエイリアスは変更されずに保持され、適用されるカスタムマッピングに基づいて検証されます。返されるロケールコードは[コンストラクタのルール](/docs/platform/core/reference/gt-class/constructor#how-it-works)に従います。

### `projectId` [#project-id]

**型** `string` · **任意** · **デフォルト** `process.env.GT_PROJECT_ID`

プロジェクト ID。未指定の場合は、`GT_PROJECT_ID` 環境変数が使用されます。

### `baseUrl` [#base-url]

**型** `string` · **任意** · **デフォルト** `https://api.gtx.dev`

API エンドポイントです。デプロイ環境が別のエンドポイントを使用している場合にのみ上書きしてください。

### `customMapping` [#custom-mapping]

**型** [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) · **任意**

カスタムのロケールコードマッピングと、ロケールプロパティのオーバーライドです。 ([`CustomMapping`](/docs/platform/core/reference/types/custom-mapping)を参照してください) 。

## 例 [#example]

```typescript
// 基本的なセットアップ
const gt = new GT({
  apiKey: 'your-api-key',
  sourceLocale: 'en',
  targetLocale: 'es',
  locales: ['en', 'es', 'fr']
});
```

```typescript
// 環境変数を使用する場合
const gt = new GT({
  sourceLocale: 'en',
  targetLocale: 'es'
});
// 環境変数からGT_API_KEYとGT_PROJECT_IDを使用
```

## Sitemap

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