# General Translation Python SDKs: m_fallback
URL: https://generaltranslation.com/en-US/docs/python/reference/functions/m-fallback.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Resolve an encoded message from msg, or interpolate a plain string, in General Translation Python. API reference for m_fallback.

Resolves a value produced by [`msg`](/docs/python/reference/functions/msg): if it is an encoded message it decodes it, otherwise it interpolates the plain string. Use it at render time when a value may or may not carry encoded options.

## Overview [#overview]

Call `m_fallback` with an encoded string (or `None`) and optional interpolation variables. It returns the decoded message when the input is a real encoded message, the interpolated string when it is plain, or the input unchanged when it is falsy.

```python
from gt_i18n import m_fallback

m_fallback(encoded_message)
```

Signature:

```python
m_fallback(encoded_msg: str | None, **kwargs: object) -> str | None
```

Import `m_fallback` from `gt_i18n`. It is not re-exported by the framework packages.

## How it works [#how-it-works]

- **Empty input.** A falsy `encoded_msg` (such as `None` or `""`) is returned unchanged.
- **Encoded detection.** It decodes the options and checks whether they represent an encoded translation (they contain both `__hash` and `__source`).
- **Decode or interpolate.** If encoded, it returns [`decode_msg`](/docs/python/reference/functions/decode-msg) of the input. Otherwise it delegates to [`t_fallback`](/docs/python/reference/functions/t-fallback), interpolating the string with `kwargs`.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`encoded_msg`](#encoded-msg) | An encoded [`msg`](/docs/python/reference/functions/msg) result, a plain string, or `None`. | `str \| None` | No | — |
| [`kwargs`](#kwargs) | Variables used only when interpolating a plain string. | keyword args | Yes | — |

### `encoded_msg` [#encoded-msg]

**Type** `str | None` · **Required**

The value to resolve. May be an encoded [`msg`](/docs/python/reference/functions/msg) result, a plain string, or `None`.

### `kwargs` [#kwargs]

**Type** keyword arguments · **Optional**

Interpolation variables, applied only when the input is a plain (non-encoded) string.

## Returns [#returns]

**Type** `str | None`

The decoded message, the interpolated plain string, or the falsy input unchanged.

## Example [#example]

```python
from gt_i18n import msg, m_fallback

encoded = msg("Save", _context="button")
m_fallback(encoded)              # "Save"
m_fallback("Hello, {name}!", name="Alice")  # "Hello, Alice!"
m_fallback(None)                 # None
```

## Sitemap

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