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

[`getLocaleEmoji`](/docs/platform/core/reference/gt-class-methods/locales/get-locale-emoji) は、General Translation のコアライブラリに含まれるスタンドアロンのユーティリティ関数で、ロケールコードに対応する絵文字の旗または記号を返します。ロケールのリージョンに基づいて国または地域の旗を選択し、カスタム絵文字マッピングにも対応しています。

## 概要 [#overview]

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

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

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

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

シグネチャ:

```typescript
getLocaleEmoji(locale: string, customMapping?: CustomMapping): string
```

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

* **リージョンベースの選択。** ロケールのリージョン (存在する場合) を使って、Unicode の Regional Indicator Symbols に基づき旗の絵文字を選択します。特定の言語では既定の絵文字にフォールバックします。
* **カスタムマッピングの優先。** [`customMapping`](/docs/platform/core/reference/types/custom-mapping) で定義された絵文字は、リージョンベースの選択よりも優先されます。
* **フォールバック。** 認識できないロケールの場合は、既定の地球儀の絵文字 (`🌍`) を返します。

## パラメーター [#parameters]

| パラメーター                             | 説明                           | 型                                                                     | 任意  | デフォルト |
| ---------------------------------- | ---------------------------- | --------------------------------------------------------------------- | --- | ----- |
| [`locale`](#locale)                | 絵文字を取得する対象の BCP-47 ロケールコード。  | `string`                                                              | いいえ | —     |
| [`customMapping`](#custom-mapping) | ロケールコードと絵文字の上書きに使うカスタムマッピング。 | [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) | はい  | —     |

### `locale` [#locale]

**型** `string` · **必須**

絵文字を取得する対象の BCP-47 ロケールコードです。

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

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

ロケールコードや絵文字のオーバーライド用の、任意のカスタムマッピングです。

## 戻り値 [#returns]

**型** `string`

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

* リージョンを含むロケールの場合は、国または地域の旗の絵文字 (例: `🇺🇸`, `🇫🇷`, `🇯🇵`) 。
* マッピングで定義されている場合は、カスタム絵文字。
* 認識されないロケールの場合は、デフォルトの地球の絵文字 (`🌍`) 。

## 例 [#examples]

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

// 一般的な国旗
console.log(getLocaleEmoji('en-US')); // "🇺🇸"
console.log(getLocaleEmoji('fr-FR')); // "🇫🇷"
console.log(getLocaleEmoji('de-DE')); // "🇩🇪"
console.log(getLocaleEmoji('ja-JP')); // "🇯🇵"
console.log(getLocaleEmoji('zh-CN')); // "🇨🇳"

// 複数の言語を持つリージョン
console.log(getLocaleEmoji('en-CA')); // "🇨🇦"
console.log(getLocaleEmoji('fr-CA')); // "🇨🇦"
console.log(getLocaleEmoji('de-CH')); // "🇨🇭"
console.log(getLocaleEmoji('fr-CH')); // "🇨🇭"
```

## メモ [#notes]

* Unicode の Regional Indicator Symbol を使用して旗の絵文字を返します。
* カスタムマッピングの絵文字は、リージョンベースの選択よりも優先されます。
* 幅広い対応のため、ISO 3166-1 alpha-2 のすべてのリージョンコードをサポートしています。

## Sitemap

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