# General Translation Python SDKs: get_default_locale
URL: https://generaltranslation.com/zh/docs/python/reference/functions/get-default-locale.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 在 General Translation Python 中读取已配置的源区域设置。get_default_locale 的 API 参考。

返回当前活动的 [`I18nManager`](/docs/python/reference/classes/i18n-manager) 的默认 (源) 区域设置。这是你的内容所使用的区域设置，也是找不到翻译时使用的后备内容。

## 概览 [#overview]

调用不带参数的 `get_default_locale`，即可获取已配置的默认区域设置代码。

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

default = get_default_locale()  # 例如 "en"
```

签名：

```python
get_default_locale() -> str
```

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

## 工作方式 [#how-it-works]

* **读取配置。** 它返回管理器的 `default_locale`，该值由 `default_locale` 参数、`defaultLocale` 配置键或库默认值 `"en"` 解析得到。

## 参数 [#parameters]

`get_default_locale` 不接收任何参数。

## 返回值 [#returns]

**类型** `str`

默认区域设置代码。

## 示例 [#example]

```python
from gt_flask import get_default_locale

default = get_default_locale()  # 例如 "en"
```

## Sitemap

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