# General Translation Python SDKs: get_version_id
URL: https://generaltranslation.com/zh/docs/python/reference/functions/get-version-id.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 在 General Translation Python 中读取当前固定的翻译版本 id。get_version_id 的 API 参考。

返回当前 source 配置的版本 id；如果未设置，则返回 `None`。版本 id 用于指定应用加载哪个已发布的翻译版本。

## 概览 [#overview]

调用不带任何参数的 `get_version_id`。该值会从当前激活的 [`I18nManager`](/docs/python/reference/classes/i18n-manager) 中读取。

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

version = get_version_id()
```

签名：

```python
get_version_id() -> str | None
```

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

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

* **读取管理器。** 返回管理器的 `version_id`，其值来自 `version_id` 参数或 `_versionId` 配置键。
* **可选。** 如果未配置版本 id，则返回 `None`。

## 参数 [#parameters]

`get_version_id` 无需任何参数。

## 返回值 [#returns]

**类型** `str | None`

已配置的 version id，或 `None`。

## 示例 [#example]

```python
from gt_i18n import get_version_id

get_version_id()  # 例如，"v_abc123" 或 None
```

## Sitemap

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