# General Translation React SDKs (gt-react, gt-next, gt-react-native): useLocaleProperties
URL: https://generaltranslation.com/ja/docs/react/reference/hooks/use-locale-properties.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: ロケールの表示メタデータを読み取ります。useLocaleProperties の API リファレンス。

`useLocaleProperties` フック は、ロケールコードを人が読める詳細情報 (名前、ネイティブ名、言語、リージョン、スクリプト) に解決します。

*`gt-react`、`gt-next`、`gt-react-native` で利用できます。*

*注: `gt-tanstack-start` では export されていません。*

## 概要 [#overview]

`useLocaleProperties` にロケールコードを渡すと、そのプロパティを取得できます。

*例では `gt-react` からインポートしています。代わりに、お使いのフレームワークのパッケージからインポートしてください。*

```tsx
import { useLocale, useLocaleProperties } from 'gt-react';

export default function LocaleInfo() {
  const locale = useLocale();
  const props = useLocaleProperties(locale); // [!code highlight]
  return (
    <div>
      <p>Name: {props.name}</p>
      <p>Native name: {props.nativeName}</p>
      <p>Region: {props.regionName}</p>
    </div>
  );
}
```

*注: `gt-react` では、[`<GTProvider>`](/docs/react/reference/components/gt-provider) の配下で `useLocaleProperties` を呼び出してください。`gt-next` では、サーバーコンポーネント内でも使用できます。*

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

このフックは、指定されたロケールコードを対応する [`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) オブジェクトに変換します。これは、カスタムのロケールセレクターを作成したり、ロケールのメタデータをユーザーに表示したりする際に役立ちます。

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

| パラメーター              | 説明       | 型        | 任意  | デフォルト |
| ------------------- | -------- | -------- | --- | ----- |
| [`locale`](#locale) | 対象のロケール。 | `string` | いいえ | —     |

### `locale` [#locale]

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

`en-US` や `ja` などの BCP 47 ロケールコードです。

## 戻り値 [#returns]

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

ロケールを表すオブジェクトです。主なフィールドは次のとおりです。

| フィールド                      | 説明                                | 型        |
| -------------------------- | --------------------------------- | -------- |
| `code`                     | `en-US` などのロケールコード。               | `string` |
| `name`                     | `American English` などのロケールの英語名。   | `string` |
| `nativeName`               | そのロケールの言語での名称。                    | `string` |
| `languageCode`             | `en` などの言語サブタグ。                   | `string` |
| `languageName`             | 言語の英語名。                           | `string` |
| `nativeLanguageName`       | その言語での言語名。                        | `string` |
| `nameWithRegionCode`       | `English (US)` などの、リージョンを含むロケール名。 | `string` |
| `nativeNameWithRegionCode` | リージョンを含む、そのロケールの言語での名称。           | `string` |
| `regionCode`               | `US` などのリージョンサブタグ。                | `string` |
| `regionName`               | リージョンの英語名。                        | `string` |
| `nativeRegionName`         | そのロケールの言語でのリージョン名。                | `string` |
| `scriptCode`               | `Latn` などのスクリプトサブタグ。              | `string` |
| `scriptName`               | スクリプトの英語名。                        | `string` |
| `nativeScriptName`         | そのロケールの言語でのスクリプト名。                | `string` |
| `maximizedCode`            | `en-Latn-US` などの完全に展開されたロケールコード。  | `string` |
| `emoji`                    | ロケールのリージョンに対応する絵文字。               | `string` |

 (フィールドの完全な一覧については、[`LocaleProperties`](/docs/platform/core/reference/types/locale-properties) を参照してください) 。

## メモ [#notes]

* `useLocaleProperties` は同期的に動作し、サーバーコンポーネントとクライアントコンポーネントの両方で使えます。
* アクティブなロケールを取得するには、[`useLocale`](/docs/react/reference/hooks/use-locale) を使用します。

## Sitemap

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