# General Translation Python SDKs: decode_options URL: https://generaltranslation.com/ja/docs/python/reference/functions/decode-options.mdx --- title: decode_options description: General Translation Python で、エンコードされた msg の結果から options 辞書を抽出します。decode_options の API リファレンス。 --- [`msg`](/docs/python/reference/functions/msg) によって生成された文字列から、options 辞書を抽出します。最後のコロンの後にある base64 ペイロードをデコードします。 ## 概要 [#overview] エンコードされた `msg` の結果を渡して `decode_options` を呼び出します。入力にコロンが含まれておらず、または ペイロード が有効でない場合は `None` を、そうでない場合はデコードされた options の dict を返します。 ```python from gt_i18n import decode_options decode_options(encoded_message) ``` シグネチャ: ```python decode_options(encoded_msg: str) -> dict[str, object] | None ``` `decode_options` を `gt_i18n` からインポートします。これはフレームワークのパッケージからは再エクスポートされません。 ## 仕組み [#how-it-works] * **最後のコロンで分割します。** 最後のコロン以降のテキストを取り出して Base64 デコードし、JSON ペイロード を解析します。 * **無効な入力またはプレーンな入力。** コロンが存在しない場合、または ペイロード を Base64 デコードできない、もしくは JSON として解析できない場合は、`None` を返します。 * **ペイロード の内容。** デコードされた ペイロード には、ユーザー変数に加えて、`__source` や `__hash` などの予約済み key が含まれます。 ## パラメータ [#parameters] | パラメータ | 説明 | Type | 任意 | デフォルト | | ----------------------------- | ----------------- | ----- | --- | ----- | | [`encoded_msg`](#encoded-msg) | `msg` をエンコードした結果。 | `str` | いいえ | — | ### `encoded_msg` [#encoded-msg] **Type** `str` · **必須** オプションの読み取り元となる、エンコードされた `msg` の結果。 ## 戻り値 [#returns] **型** `dict[str, object] | None` デコードされた options の dict、または入力に有効な options のペイロードが含まれていない場合は `None`。 ## 例 [#example] ```python from gt_i18n import msg, decode_options encoded = msg("Save", _context="button") decode_options(encoded) # {"_context": "button", "__source": "Save", "__hash": "..."} decode_options("Plain") # None ```