> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/common/network-environment/language.md).

# 语言

`getLocale` 该函数 **获取当前用户的地区（locale）信息，并**，基于此 **可用于将应用处理为多语言的 API**。

如果让用户能够用熟悉的语言使用应用，整体的 **用户体验和可访问性**都可以大幅提升。可用于字符串翻译、日期·时间格式、数字表示等所有需要本地化的领域。

{% hint style="info" %}
**请参考**

* 如果无法获取地区信息，则默认 `'ko-KR'`会返回这个。
* 这个 API 和示例 **仅在 Toss 应用环境中** 可以查看。
  {% endhint %}

### 获取用户语言

**SDK 函数：** `getLocale`

**签名**

```typescript
function getLocale(): string;
```

**返回值**

* string

  返回用户的地区信息。

**获取当前用户的地区信息**

```tsx
import { getLocale } from '@apps-in-toss/framework';
import { Text } from 'react-native';

function MyPage() {
  const locale = getLocale();

  return <Text>用户的地区信息：{locale}</Text>;
}
```

**体验示例应用**

[apps-in-toss-examples](https://github.com/toss/apps-in-toss-examples) 在仓库中 [with-locale](https://github.com/toss/apps-in-toss-examples/tree/main/with-locale) 下载代码，或扫描下方二维码亲自体验。

二维码链接：intoss\://with-locale


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/common/network-environment/language.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
