# gt-node: General Translation Node.js SDK: getLocaleProperties
URL: https://generaltranslation.com/ja/docs/node/reference/functions/get-locale-properties.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: General Translation gt-node でロケールの表示用メタデータを取得します。getLocaleProperties の API リファレンス。

ロケールの名前、ネイティブ名、言語、リージョン、文字体系情報などのメタデータを返します。ロケールセレクターを作成したり、ロケールのメタデータをユーザーに表示したりする際に使用します。

## 概要 [#overview]

ロケールコードを指定して `getLocaleProperties` を呼び出すか、引数を省略して現在のロケールを使用します。戻り値は [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) オブジェクトです。

```ts
import { getLocaleProperties } from 'gt-node';

const props = getLocaleProperties('en-US');
console.log(props.name); // 'American English'
```

シグネチャ:

```ts
getLocaleProperties(locale?: string): LocaleProperties
```

*注: この関数は同期関数なので、await する必要はありません。*

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

* **ロケールのフォールバック。** `locale` を省略すると、現在のロケールを指します。
* **派生サブタグ。** 言語・文字体系・リージョンの各サブタグ、その表示名、および最大化形式を解決します。
* **同期的。** すぐに戻り、ネットワークリクエストは不要です。

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

| パラメーター              | 説明                    | 型        | 任意 | デフォルト   |
| ------------------- | --------------------- | -------- | -- | ------- |
| [`locale`](#locale) | 説明対象の BCP 47 ロケールコード。 | `string` | はい | 現在のロケール |

### `locale` [#locale]

**型** `string` · **省略可** · **デフォルト** 現在のロケール

BCP 47 のロケールコードです (例: `'en-US'`、`'ja'`) 。指定しない場合は、現在のロケールが使用されます。

## 戻り値 [#returns]

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

以下のフィールドを持つ [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) オブジェクトです。

| Field                      | 型        | 説明                                                 |
| -------------------------- | -------- | -------------------------------------------------- |
| `code`                     | `string` | ロケールコード (例: `'en-US'`) 。                           |
| `name`                     | `string` | ロケールの英語名 (例: `'American English'`) 。               |
| `nativeName`               | `string` | そのロケール自身の言語での名称 (例: `'American English'`) 。        |
| `languageCode`             | `string` | 言語サブタグ (例: `'en'`) 。                               |
| `languageName`             | `string` | 言語の英語名 (例: `'English'`) 。                          |
| `nativeLanguageName`       | `string` | その言語自身での言語名 (例: `'English'`) 。                     |
| `nameWithRegionCode`       | `string` | リージョンを含むロケール名 (例: `'English (US)'`) 。              |
| `nativeNameWithRegionCode` | `string` | リージョンを含む、そのロケール自身の言語での名称。                          |
| `regionCode`               | `string` | リージョンサブタグ (例: `'US'`) 。                            |
| `regionName`               | `string` | リージョンの英語名 (例: `'United States'`) 。                 |
| `nativeRegionName`         | `string` | そのロケール自身の言語でのリージョン名。                               |
| `scriptCode`               | `string` | 文字体系サブタグ (例: `'Latn'`) 。                           |
| `scriptName`               | `string` | 文字体系の英語名 (例: `'Latin'`) 。                          |
| `nativeScriptName`         | `string` | そのロケール自身の言語での文字体系名。                                |
| `maximizedCode`            | `string` | 完全に展開されたロケールコード (例: `'en-Latn-US'`) 。              |
| `maximizedName`            | `string` | 最大化されたロケールの英語名 (例: `'American English (Latin)'`) 。 |
| `nativeMaximizedName`      | `string` | その言語自身での最大化されたロケール名。                               |
| `minimizedCode`            | `string` | 最小限のロケールコード (例: `'en'`) 。                          |
| `minimizedName`            | `string` | 最小化されたロケールの英語名。                                    |
| `nativeMinimizedName`      | `string` | その言語自身での最小化されたロケール名。                               |
| `emoji`                    | `string` | そのロケールを表す国旗または絵文字。                                 |

## 例 [#examples]

```ts title="handler.js"
// 基本的な使い方
import { getLocaleProperties } from 'gt-node';

app.get('/api/locale-info', (req, res) => {
  const props = getLocaleProperties('ja');
  res.json({
    name: props.name,             // 'Japanese'
    nativeName: props.nativeName, // '日本語'
    script: props.scriptName,     // 'Japanese'
  });
});
```

## メモ [#notes]

* この関数は同期関数のため、`await` は不要です。
* ロケールセレクターの作成や、ユーザーへのロケールのメタデータ表示に役立ちます。

## Sitemap

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