# General Translation Platform: getLocaleEmoji
URL: https://generaltranslation.com/ja/docs/platform/core/reference/gt-class-methods/locales/get-locale-emoji.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: ロケールまたはリージョンに対応する絵文字マーカーを返します。getLocaleEmoji の API リファレンス。

[GT](/docs/platform/core/reference/gt-class/constructor) インスタンス上で、リージョンに基づいてロケールコードに対応する絵文字の旗または記号を取得します。General Translation は国や地域の旗の絵文字を返し、特定のリージョンがない言語向けのフォールバックや、マッピングによるカスタム絵文字にも対応しています。

## 概要 [#overview]

[`GT`](/docs/platform/core/reference/gt-class/constructor) インスタンスで、必要に応じてロケールコードを指定して `getLocaleEmoji` を呼び出します。省略した場合は、そのインスタンスの `targetLocale` が使われます。

```typescript
const gt = new GT({ sourceLocale: 'en', targetLocale: 'fr-CA' });

const emoji = gt.getLocaleEmoji('fr-CA');
console.log(emoji); // "🇨🇦" (カナダの国旗)

const usEmoji = gt.getLocaleEmoji('en-US');
console.log(usEmoji); // "🇺🇸" (アメリカの国旗)

const enEmoji = gt.getLocaleEmoji('en');
console.log(enEmoji); // "🇺🇸" (アメリカの国旗)
```

シグネチャ:

```typescript
getLocaleEmoji(locale?: string): string
```

*注: `getLocaleEmoji` はローカルで実行されるため、APIキーは不要です。`locale` を省略した場合は、インスタンスの `targetLocale` が使われます。`GT` インスタンスを使わずに参照する場合は、スタンドアロンの [`getLocaleEmoji`](/docs/platform/core/reference/utility-functions/locales/get-locale-emoji) を参照してください。*

## 仕組み [#how-it-works]

* **リージョンベースの選択。** ロケールのリージョンコード (利用可能な場合) を使って、Unicode の地域指示記号から構成される国旗の emoji を選択します。
* **Custom mapping の優先。** [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) で定義された emoji は、リージョンベースの選択より優先されます。
* **フォールバック。** リージョンのない一部の言語では言語固有の emoji を返し、認識されない、または無効なロケールにはデフォルトの地球の emoji `🌍` を返します。
* **ロケール未指定。** ロケールが指定されておらず、インスタンスに `targetLocale` も設定されていない場合は、`Error` をスローします。

## パラメータ [#parameters]

| パラメータ               | 説明                          | 型        | 任意 | デフォルト               |
| ------------------- | --------------------------- | -------- | -- | ------------------- |
| [`locale`](#locale) | 絵文字を取得する対象の BCP-47 ロケールコード。 | `string` | はい | `this.targetLocale` |

### `locale` [#locale]

**Type** `string` · **任意** · **デフォルト** `this.targetLocale`

emoji を取得する対象の BCP-47 ロケールコードです。指定しない場合は、インスタンスの `targetLocale` が使用されます。

## 戻り値 [#returns]

**型** `string`

ロケールを表す旗の絵文字または記号です。

* リージョンを含むロケールでは、国または地域の旗の絵文字 (例: `🇺🇸`, `🇫🇷`, `🇯🇵`) 
* リージョンのない一部の言語では、言語固有の絵文字
* 認識できないロケールでは、デフォルトの地球の絵文字 (`🌍`) 

ロケールが指定されておらず、インスタンスに `targetLocale` も設定されていない場合は、`Error` をスローします。

## 例 [#examples]

```typescript
const gt = new GT({ sourceLocale: 'en', targetLocale: 'es' });

// targetLocaleのemojiを取得
console.log(gt.getLocaleEmoji()); // "🇪🇸" (uses targetLocale 'es')

// 異なるロケールのemojiを取得
console.log(gt.getLocaleEmoji('en-US')); // "🇺🇸"
console.log(gt.getLocaleEmoji('fr-FR')); // "🇫🇷"
console.log(gt.getLocaleEmoji('de-DE')); // "🇩🇪"
console.log(gt.getLocaleEmoji('ja-JP')); // "🇯🇵"
console.log(gt.getLocaleEmoji('zh-CN')); // "🇨🇳"
```

## メモ [#notes]

* 利用可能な場合は、ロケールのリージョンコードに基づいて国旗のemojiを返します。
* カスタムマッピングのemojiは、リージョンベースの選択よりも優先されます。
* 国旗の生成には Unicode の地域指示記号を使用します。
* 認識できない、または無効なロケールの場合は、デフォルトで `🌍` (地球儀) を返します。
* Unicode emoji をサポートする最新のブラウザーおよびオペレーティングシステムで利用できます。

## Sitemap

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