# General Translation Python SDKs: decode_vars URL: https://generaltranslation.com/ja/docs/python/reference/functions/decode-vars.mdx --- title: decode_vars description: Python で文字列内の General Translation の変数マーカーを値に置き換えます。decode_vars の API リファレンス。 --- ICU 文字列内の `{_gt_, select, other {value}}` 変数マーカーを、埋め込まれた値に置き換えます。[`declare_var`](/docs/python/reference/functions/declare-var) で構築した文字列から、値が埋め込まれた通常の文字列を復元するために使用します。 ## 概要 [#overview] General Translation の変数マーカーを含む可能性がある ICU 文字列を `decode_vars` に渡します。戻り値は、各マーカーが埋め込まれた値に置き換えられた文字列です。 ```python from gt_i18n import declare_var, decode_vars marked = f"Signed in as {declare_var('a@b.com', name='email')}" decode_vars(marked) # "Signed in as a@b.com" ``` シグネチャ: ```python decode_vars(icu_string: str) -> str ``` `gt_i18n` とフレームワークパッケージが `generaltranslation.static` から再エクスポートします。 ## 仕組み [#how-it-works] * **高速パス。** 文字列に `_gt_` マーカーが含まれていない場合は、変更せずそのまま返されます。 * **マーカーの展開。** ICU AST をたどり、インデックスのない `_gt_` select を見つけて、それぞれを `other` 句の値に置き換えます (存在しない場合は空文字列) 。 ## パラメータ [#parameters] | パラメータ | 説明 | 型 | 任意 | デフォルト | | --------------------------- | -------------------------------------- | ----- | --- | ----- | | [`icu_string`](#icu-string) | 変数マーカーを含む可能性のある ICU MessageFormat 文字列。 | `str` | いいえ | — | ### `icu_string` [#icu-string] **型** `str` · **必須** General Translation の変数マーカーを含む可能性のある ICU MessageFormat 文字列。 ## 戻り値 [#returns] **型** `str` 変数マーカーが埋め込み値に置き換えられた文字列。 ## 例 [#example] ```python from gt_i18n import declare_var, decode_vars marked = f"You have {declare_var('5', name='count')} messages" decode_vars(marked) # "You have 5 messages" ```