# Vue: MessagesFunction
URL: https://generaltranslation.com/en-US/docs/vue/reference/types/messages-function.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Resolve registered messages, raw strings, and nullish values from the active catalog. API reference for MessagesFunction.

[`useMessages()`](/docs/vue/reference/composables/use-messages) returns this callback. It decodes values created by [`msg()`](/docs/vue/reference/functions/msg) and also accepts an ordinary source string.

## Overview [#overview]

```ts
type MessagesFunction = <T extends string | null | undefined>(
  message: T,
  options?: GTStringOptions
) => T extends string ? string : T;
```

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`message`](#message) | Encoded message, raw source string, `null`, or `undefined`. | `T extends string \| null \| undefined` | No | — |
| [`options`](#options) | Context for a raw source string. | [`GTStringOptions`](/docs/vue/reference/types/gt-string-options) | Yes | `{}` |

## Parameters [#parameters]

### `message`

**Type** `T extends string | null | undefined` · **Required**

Pass a value returned by [`msg()`](/docs/vue/reference/functions/msg), an ordinary source string, or a nullish value. Encoded strings carry their original source, hash, and optional `$context`.

### `options`

**Type** [`GTStringOptions`](/docs/vue/reference/types/gt-string-options) · **Optional** · **Default** `{}`

For a raw string, `$context` participates in the catalog hash. For an encoded value, metadata stored by [`msg()`](/docs/vue/reference/functions/msg) takes precedence and call-site options are ignored.

## Return value [#returns]

| Input | Return type | Behavior |
| --- | --- | --- |
| `string` | `string` | Returns the catalog translation or decoded source fallback. |
| `null` | `null` | Returns `null` unchanged. |
| `undefined` | `undefined` | Returns `undefined` unchanged. |

The conditional generic preserves nullish input types, which lets optional messages pass through without a separate guard.

## Resolution [#resolution]

For an encoded message, the callback decodes the stored source, `$context`, and precomputed hash before lookup. For an ordinary string, it calculates the hash from the string and call-site `$context`.

Both paths require a string value in the active catalog. Missing or non-string entries return the source text. No ICU formatting or interpolation is performed; braces remain literal.

Call the callback from a Vue template, computed value, or reactive effect when the result should update after a [`createGT()`](/docs/vue/reference/functions/create-gt) plugin loads a catalog or changes locale.

## Example [#example]

```vue title="src/PageTitle.vue"
<script setup lang="ts">
import { msg, useMessages } from 'gt-vue';

const title = msg('Settings', { $context: 'page title' });
const m = useMessages();
</script>

<template>
  <h1>{{ m(title) }}</h1>
</template>
```

## Sitemap

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