# General Translation Python SDKs: get_locales
URL: https://generaltranslation.com/zh/docs/python/reference/functions/get-locales.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 列出 General Translation Python 中配置的受支持区域设置。get_locales 的 API 参考。

返回当前活动的 [`I18nManager`](/docs/python/reference/classes/i18n-manager) 支持的区域设置列表，其中始终包含默认区域设置。

## 概览 [#overview]

调用 `get_locales` 时不传任何参数，即可获取受支持的区域设置代码。

```python
from gt_flask import get_locales  # 或：from gt_fastapi import get_locales，或：from gt_i18n import get_locales

locales = get_locales()  # 例如 ["en", "es", "fr"]
```

签名：

```python
get_locales() -> list[str]
```

*注意：它会读取当前生效的管理器，因此必须先运行 [`initialize_gt`](/docs/python/reference/functions/initialize-gt) (或 [`set_i18n_manager`](/docs/python/reference/functions/set-i18n-manager)) ，否则会抛出 `RuntimeError`。*

## 工作原理 [#how-it-works]

* **读取配置。** 它会返回从配置中解析出的 `locales`，并且始终包含默认区域设置。
* **顺序。** 该列表基于集合构建，因此无法保证顺序固定。

## 参数 [#parameters]

`get_locales` 无需传入参数。

## 返回值 [#returns]

**类型** `list[str]`

支持的区域设置代码。

## 示例 [#example]

```python
from gt_flask import get_locales

locales = get_locales()  # 例如 ["en", "es", "fr"]
```

## Sitemap

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