# General Translation Platform: isSameLanguage URL: https://generaltranslation.com/ja/docs/platform/core/reference/gt-class-methods/locales/is-same-language.mdx --- title: isSameLanguage description: 2 つのロケールが同じ基本言語かどうかを確認します。isSameLanguage の API リファレンス。 --- [GT](/docs/platform/core/reference/gt-class/constructor) インスタンスで、複数の BCP-47 ロケールコードが、リージョンやスクリプトの違いを無視した場合に同じ基本言語を表すかどうかを確認します。General Translation はこれを使用して言語の互換性を判断し、Content を言語ファミリーごとにグループ化します。 ## 概要 [#overview] [`GT`](/docs/platform/core/reference/gt-class/constructor) インスタンスに対して、2 つ以上のロケールコード (またはロケールコードの配列) を指定して `isSameLanguage` を呼び出します。すべてでベース言語が同じ場合は、`true` を返します。 ```typescript const gt = new GT({ sourceLocale: 'en-US', targetLocale: 'es-ES' }); console.log(gt.isSameLanguage('en-US', 'en-GB')); // true console.log(gt.isSameLanguage('en-US', 'es-ES')); // false ``` シグネチャ: ```typescript isSameLanguage(...locales: (string | string[])[]): boolean ``` *注: `isSameLanguage` はローカルで実行されるため、API Key は不要です。`GT` インスタンスを使わずに比較する場合は、スタンドアロンの [`isSameLanguage`](/docs/platform/core/reference/utility-functions/locales/is-same-language) を参照してください。* ## 動作の仕組み [#how-it-works] * **基本言語を比較。** 最初のハイフンより前の基本言語コードだけを比較します。 * **サブタグは無視。** リージョン、スクリプト、バリアントの違いは無視されます。 * **可変個の入力。** 可変個のロケールパラメータに対応しており、文字列、配列、またはその混在を受け付けます。 ## パラメータ [#parameters] | パラメータ | 説明 | 型 | 省略可能 | デフォルト | | --------------------- | ------------------------------------ | ------------------------ | ---- | ----- | | [`locales`](#locales) | 比較するロケールコード、またはロケールコードの配列を可変長で指定します。 | `(string \| string[])[]` | いいえ | — | ### `...locales` [#locales] **型** `(string | string[])[]` · **必須** 比較対象となる、可変長のロケールコード (文字列) またはロケールコードの配列。指定するすべてのロケールは、同じベース言語を表している必要があります。 ## 戻り値 [#returns] **型** `boolean` すべてのロケールコードが同じベース言語を表している場合は `true`、それ以外の場合は `false` です。 ## 例 [#examples] ```typescript const gt = new GT({ sourceLocale: 'en-US', targetLocale: 'es-ES' }); // 同じ言語、異なるリージョン console.log(gt.isSameLanguage('en-US', 'en-GB')); // true console.log(gt.isSameLanguage('es-ES', 'es-MX')); // true console.log(gt.isSameLanguage('zh-CN', 'zh-TW')); // true // 異なる言語 console.log(gt.isSameLanguage('en-US', 'es-ES')); // false console.log(gt.isSameLanguage('fr-FR', 'de-DE')); // false // バリアント付きの基本言語 console.log(gt.isSameLanguage('en', 'en-US', 'en-GB')); // true ``` ## メモ [#notes] * 基本言語コード (最初のハイフンより前) だけを比較します。 * リージョン、スクリプト、バリアントの違いは無視します。 * 言語ごとのコンテンツ整理に不可欠です。 * 数が可変のロケールパラメータに対応します。