# General Translation Platform: isSameLanguage
URL: https://generaltranslation.com/ja/docs/platform/core/reference/utility-functions/locales/is-same-language.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: GT インスタンスなしで、2 つのロケールが同じ基本言語かどうかを確認します。isSameLanguage の API リファレンスです。

[`isSameLanguage`](/docs/platform/core/reference/gt-class-methods/locales/is-same-language) は、General Translation のコアライブラリに含まれる単体で使えるユーティリティ関数で、複数の BCP-47 ロケールコードがリージョンの違いを無視したときに同じ基本言語を表すかどうかを確認します。

## 概要 [#overview]

`generaltranslation` から `isSameLanguage` を直接インポートし、2 つ以上のロケールコードを渡して呼び出します。API Key や [GT](/docs/platform/core/reference/gt-class/constructor) インスタンスは必要ありません。インスタンスベースの同等の機能を使う場合は、[`GT`](/docs/platform/core/reference/gt-class/constructor) インスタンスの [`isSameLanguage`](/docs/platform/core/reference/gt-class-methods/locales/is-same-language) メソッドを使用してください。

```typescript
import { isSameLanguage } from 'generaltranslation';

console.log(isSameLanguage('en-US', 'en-GB')); // true（同じ言語）
console.log(isSameLanguage('en-US', 'es-ES')); // false（異なる言語）
```

シグネチャ:

```typescript
isSameLanguage(...locales: (string | string[])[]): boolean
```

## 動作の仕組み [#how-it-works]

* **基本言語コードの比較。** 最初のハイフンより前にある基本言語コードのみを比較し、リージョン、スクリプト、バリアントの違いは無視します。
* **可変長入力。** 可変個の引数を受け取り、各引数にはロケール文字列またはロケール文字列の配列を指定できます。

## パラメータ [#parameters]

| パラメータ                 | 説明                      | 型                        | 任意  | デフォルト |
| --------------------- | ----------------------- | ------------------------ | --- | ----- |
| [`locales`](#locales) | 比較対象のロケールコードを2つ以上指定します。 | `(string \| string[])[]` | いいえ | —     |

### `locales` [#locales]

**型** `(string | string[])[]` · **必須**

ロケールコードを比較するための可変長引数です。各引数には、ロケール文字列またはロケール文字列の配列を渡せます。

## 戻り値 [#returns]

**型** `boolean`

すべてのロケールコードが同じ基本言語を表す場合は `true`、そうでない場合は `false` です。

## 例 [#examples]

```typescript
import { isSameLanguage } from 'generaltranslation';

// 同じ言語、異なるリージョン
console.log(isSameLanguage('en-US', 'en-GB')); // true
console.log(isSameLanguage('es-ES', 'es-MX')); // true
console.log(isSameLanguage('zh-CN', 'zh-TW')); // true

// 異なる言語
console.log(isSameLanguage('en-US', 'es-ES')); // false
console.log(isSameLanguage('fr-FR', 'de-DE')); // false
```

## メモ [#notes]

* 最初のハイフンより前にある基本言語コードのみを比較します。
* リージョン、スクリプト、バリアントの違いは無視します。
* 言語ごとにコンテンツを整理するうえで不可欠です。
* 任意の数のパラメータに対応します。

## Sitemap

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