# General Translation Platform: getLocaleProperties
URL: https://generaltranslation.com/ja/docs/platform/core/reference/utility-functions/locales/get-locale-properties.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: GT インスタンスなしで、ロケールの詳細なプロパティを返します。getLocaleProperties の API リファレンス。

[`getLocaleProperties`](/docs/platform/core/reference/gt-class-methods/locales/get-locale-properties) は、General Translation の Core library に含まれる、GT インスタンスなしで使えるユーティリティ関数です。表示名、言語、表記体系、リージョン情報、およびそれを表す emoji を含む、ロケールコードの詳細なプロパティを返します。

## 概要 [#overview]

`generaltranslation` から `getLocaleProperties` を直接インポートし、ロケールコードと省略可能な表示用ロケールを指定して呼び出します。これには APIキー も [GT](/docs/platform/core/reference/gt-class/constructor) インスタンスも必要ありません。インスタンスベースの同等の機能を使う場合は、代わりに [`GT`](/docs/platform/core/reference/gt-class/constructor) インスタンスの [`getLocaleProperties`](/docs/platform/core/reference/gt-class-methods/locales/get-locale-properties) メソッドを使用してください。

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

const props = getLocaleProperties('fr-CA', 'en');
console.log(props.name); // "Canadian French"
console.log(props.nativeName); // "français canadien"
console.log(props.emoji); // "🇨🇦"
console.log(props.regionCode); // "CA"
```

シグネチャ：

```typescript
getLocaleProperties(
  locale: string,
  defaultLocale?: string,
  customMapping?: CustomMapping
): LocaleProperties
```

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

* **包括的なメタデータ。** 標準形と最大化形を含む、完全な [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) オブジェクトを返します。
* **ネイティブ名。** ネイティブ名は `defaultLocale` に関係なく、常にターゲットロケール自身で計算されます。
* **カスタムマッピングとの統合。** すべてのプロパティで最初にカスタムマッピングが確認され、エイリアスの解決とプロパティの上書きをサポートします。マッピングされていないコードについては標準の `Intl` API にフォールバックします。エイリアスされたロケールは正規ロケールに解決されます。

*注: 表示名には CLDR の dialect 形式が使われます。たとえば、`getLocaleProperties('es-MX', 'en').name` は &quot;Mexican Spanish&quot; (&quot;Spanish (Mexico)&quot; ではなく) になり、`nativeName` は &quot;español de México&quot; になります。*

## パラメータ [#parameters]

| パラメータ                              | 説明                                 | 型                                                                     | 任意  | デフォルト |
| ---------------------------------- | ---------------------------------- | --------------------------------------------------------------------- | --- | ----- |
| [`locale`](#locale)                | プロパティを取得する対象の BCP-47 ロケールコード。      | `string`                                                              | いいえ | —     |
| [`defaultLocale`](#default-locale) | 表示名 をローカライズするために使用するロケール。 | `string`                                                              | はい  | `en`  |
| [`customMapping`](#custom-mapping) | ロケールコードとプロパティに対するカスタムマッピング。        | [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) | はい  | —     |

### `locale` [#locale]

**Type** `string` · **Required**

プロパティの取得対象となる BCP-47 ロケールコードです。

### `defaultLocale` [#default-locale]

**Type** `string` · **任意** · **デフォルト** `en`

返される表示名のローカライズに使用するロケールです。

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

**型** [`CustomMapping`](/docs/platform/core/reference/types/custom-mapping) · **省略可能**

ロケールコードとそのプロパティのための、任意のカスタムマッピングです。

## 戻り値 [#returns]

**型** [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties)

すべてのロケール情報を含む包括的なオブジェクトです。

* `code`: 標準化されたロケールコード。
* `name`: デフォルトロケールでの表示名。
* `nativeName`: そのロケール自体での表示名。
* `languageCode`, `languageName`, `nativeLanguageName`: 言語情報。
* `regionCode`, `regionName`, `nativeRegionName`: リージョン情報。
* `scriptCode`, `scriptName`, `nativeScriptName`: 表記体系に関する情報。
* `maximizedCode`, `minimizedCode`: canonical 形式。
* `nameWithRegionCode`, `nativeNameWithRegionCode`: 表示名を組み合わせた形式。
* `emoji`: 旗、またはそのリージョンを表す emoji。

## 例 [#examples]

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

// 英語の表示名
const enProps = getLocaleProperties('es-MX', 'en');
console.log(enProps.name); // "Mexican Spanish"
console.log(enProps.languageName); // "Spanish"
console.log(enProps.regionName); // "Mexico"
console.log(enProps.emoji); // "🇲🇽"

// フランス語の表示名
const frProps = getLocaleProperties('es-MX', 'fr');
console.log(frProps.name); // "espagnol du Mexique"
console.log(frProps.languageName); // "espagnol"
console.log(frProps.regionName); // "Mexique"

// ネイティブ名は常にターゲットロケールで表示される
console.log(enProps.nativeName); // "español de México"
console.log(frProps.nativeName); // "español de México"
```

## メモ [#notes]

* GT class をインスタンス化しなくても、ロケールデータを取得できます。
* カスタムマッピング のプロパティは、標準の `Intl` API より優先されます。
* 常に完全な [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) オブジェクトが返されます。
* ネイティブ名 は常に対象のロケール自体で計算されます。

## Sitemap

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