# General Translation Python SDKs: extract_variables URL: https://generaltranslation.com/ja/docs/python/reference/functions/extract-variables.mdx --- title: extract_variables description: options dict から予約済みの GT keys を除外し、General Translation Python でユーザー variables を取得します。extract_variables の API リファレンス。 --- options dict からユーザーの interpolation variables だけを取り出し、予約済みの General Translation keys を除外して返します。これは、[`t`](/docs/python/reference/functions/t)、[`msg`](/docs/python/reference/functions/msg)、[`interpolate_message`](/docs/python/reference/functions/interpolate-message) が variables と options を分離するために使う helper です。 ## 概要 [#overview] options dict を渡して `extract_variables` を呼び出します。GT の予約済みキーを除くすべてのキーを含む新しい dict が返されます。 ```python from gt_i18n import extract_variables extract_variables({"name": "Alice", "_context": "greeting"}) # → {"name": "Alice"} ``` シグネチャ: ```python extract_variables(options: dict[str, object]) -> dict[str, object] ``` `extract_variables` は `gt_i18n` からインポートします。フレームワークパッケージからは再エクスポートされません。 ## 動作の仕組み [#how-it-works] * **予約済みのキー。** `_context`、`_id`、`_max_chars`、`__hash`、`__source`、`__fallback` は除外されます。 * **それ以外はそのまま保持。** その他のキーはすべてそのまま渡され、先頭が単一のアンダースコアのユーザーキー (たとえば `_name`) も含まれます。 * **非破壊。** 新しいdictを返し、入力は変更されません。 ## パラメータ [#parameters] | パラメータ | 説明 | 型 | 任意 | デフォルト | | --------------------- | --------------------------------------------- | ------------------- | --- | ----- | | [`options`](#options) | 予約済みの GT キー が含まれる可能性のある、options dict 全体。 | `dict[str, object]` | いいえ | — | ### `options` [#options] **型** `dict[str, object]` · **必須** options dict 全体です。予約済みの GT キーは除外され、それ以外のエントリはすべて保持されます。 ## 戻り値 [#returns] **型** `dict[str, object]` 予約済みの GT キーを取り除いた新しい dict。 ## 例 [#example] ```python from gt_i18n import extract_variables extract_variables({"_context": "x", "_id": "y", "_max_chars": 10}) # → {} extract_variables({"_name": "Alice", "_context": "greeting"}) # → {"_name": "Alice"} ```