# react-native: useLocaleProperties
URL: https://generaltranslation.com/zh/docs/react-native/api/helpers/use-locale-properties.mdx
---
title: useLocaleProperties
description: useLocaleProperties Hook 的 API 参考文档
---
{/* 自动生成:请勿直接编辑。请改为编辑 content/docs-templates/ 中的 template。 */}
## 概述
`useLocaleProperties` Hook 会返回给定区域设置的元数据,包括其名称、原生名称、语言、区域和书写系统信息。
`useLocaleProperties` 是一个客户端 Hook,*只能在客户端组件中使用*。
请确保你的应用已用 [``](/docs/react-native/api/components/gtprovider) 包裹。
## 参考
### 参数
| 参数 | 类型 | 说明 |
| -------- | -------- | ----------------------------------------- |
| `locale` | `string` | 符合 BCP 47 的区域设置代码 (例如 `'en-US'`、`'ja'`) 。 |
### 返回值
返回一个 `LocaleProperties` 对象,包含以下字段:
| 字段 | 类型 | 说明 |
| -------------------------- | -------- | -------------------------------------- |
| `code` | `string` | 区域设置代码 (例如 `'en-US'`) 。 |
| `name` | `string` | 该区域设置的英文名称 (例如 `'American English'`) 。 |
| `nativeName` | `string` | 该区域设置的原生名称。 |
| `languageCode` | `string` | 语言子标签 (例如 `'en'`) 。 |
| `languageName` | `string` | 该语言的英文名称。 |
| `nativeLanguageName` | `string` | 该语言在其自身语言中的名称。 |
| `nameWithRegionCode` | `string` | 包含区域的区域设置名称 (例如 `'English (US)'`) 。 |
| `nativeNameWithRegionCode` | `string` | 包含区域的区域设置原生名称。 |
| `regionCode` | `string` | 区域子标签 (例如 `'US'`) 。 |
| `regionName` | `string` | 该区域的英文名称。 |
| `nativeRegionName` | `string` | 该区域在区域设置自身语言中的名称。 |
| `scriptCode` | `string` | 书写系统子标签 (例如 `'Latn'`) 。 |
| `scriptName` | `string` | 该书写系统的英文名称。 |
| `nativeScriptName` | `string` | 该书写系统在区域设置自身语言中的名称。 |
| `maximizedCode` | `string` | 完全展开的区域设置代码 (例如 `'en-Latn-US'`) 。 |
***
## 示例
### 基本用法
```jsx title="LocaleInfo.jsx" copy
'use client';
import { useLocaleProperties } from 'gt-react-native';
import { useLocale } from 'gt-react-native';
export default function LocaleInfo() {
const locale = useLocale();
const props = useLocaleProperties(locale); // [!code highlight]
return (
Name: {props.name}
Native name: {props.nativeName}
Region: {props.regionName}
);
}
```
***
## 说明
* 此 Hook 是同步的,会直接返回这些属性。
* 适合用于构建自定义区域设置选择器,或向用户显示区域设置的元数据。
## 后续步骤
* 详细了解[区域设置代码](/docs/core/locales)。