# General Translation Python SDKs: declare_static
URL: https://generaltranslation.com/zh/docs/python/reference/functions/declare-static.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: General Translation Python 中 `derive` 的已弃用别名，用于将内容标记为可在构建阶段提取。declare_static 的 API 参考。

[`derive`](/docs/python/reference/functions/derive) 的已弃用别名。它会将内容标记为可供 General Translation CLI 静态分析，然后调用 [`derive`](/docs/python/reference/functions/derive)。新代码请使用 [`derive`](/docs/python/reference/functions/derive)。

## 概览 [#overview]

`declare_static` 的调用方式与 [`derive`](/docs/python/reference/functions/derive) 完全相同：用一组有限的 outcome 包裹一个静态表达式。它会发出一个 `DeprecationWarning`，并原样返回输入值。

```python
from gt_i18n import declare_static

message = t(f"The {declare_static('boy' if gender == 'male' else 'girl')} is playing.")
```

签名：

```python
declare_static(content: object) -> object
```

由 `gt_i18n` 和框架包从 `generaltranslation.static` 中重新导出。

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

* **弃用警告。** 它会触发 `DeprecationWarning`，并建议改用 [`derive`](/docs/python/reference/functions/derive)。
* **委托给 [`derive`](/docs/python/reference/functions/derive)。** 它返回 `derive(content)`——即原样返回内容——因此其行为与 [`derive`](/docs/python/reference/functions/derive) 完全一致。

## 参数 [#parameters]

| 参数                    | 描述                | 类型       | 可选 | 默认值 |
| --------------------- | ----------------- | -------- | -- | --- |
| [`content`](#content) | 具有一组有限可能取值的静态表达式。 | `object` | 否  | —   |

### `content` [#content]

**类型** `object` · **必填**

具有有限个可能取值的静态表达式。

## 返回 [#returns]

**类型** `object`

原样返回 `content`。

## 示例 [#example]

```python
# 已弃用 — 请使用 derive()
from gt_i18n import declare_static  # ❌ 已弃用
from gt_i18n import derive          # ✅ 请改用此方法
```

## Sitemap

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