# General Translation React SDKs (gt-react, gt-next, gt-react-native): getMessages
URL: https://generaltranslation.com/ja/docs/react/tanstack-start/reference/functions/get-messages.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: TanStack Start のランタイムで、General Translation を使用して登録済みメッセージを解決します。getMessages の API リファレンス。

`getMessages` 関数は、[`msg`](/docs/react/reference/functions/msg) で登録された文字列用のリゾルバーを返します。`gt-tanstack-start` からインポートします。

## 概要 [#overview]

```ts
import { getMessages, msg } from 'gt-tanstack-start';

const status = msg('Ready');
const m = await getMessages();
const translated = m(status);
```

```ts
getMessages(): Promise<MessageTranslationFunction>
```

## 仕組み [#how-it-works]

サーバーでは、`getMessages` は [`gtMiddleware`](/docs/react/tanstack-start/reference/functions/gt-middleware) によって作成されたロケールと国際化設定を読み取ります。ブラウザーでは、[`initializeGT`](/docs/react/reference/config#initialize) によって初期化された条件ストアを読み取ります。現在のランタイムに対応する翻訳を使って、エンコードされたメッセージを解決します。

サーバー呼び出しは、アクティブなミドルウェアのリクエストスコープ外では例外をスローします。

## 戻り値 [#returns]

**型** `Promise<(encodedContent: string, options?: object) => string>`

返される関数は、現在のリクエストロケールに応じて、エンコードされたコンテンツを翻訳します。[`msg`](/docs/react/reference/functions/msg) に渡された変数は、リゾルバーに渡された変数よりも優先されます。

## 例 [#example]

```ts
import { createServerFn } from '@tanstack/react-start';
import { getMessages, msg } from 'gt-tanstack-start';

const STATUS = {
  active: msg('Active'),
  paused: msg('Paused'),
};

export const loadStatus = createServerFn({ method: 'GET' }).handler(
  async () => {
    const m = await getMessages();
    return m(STATUS.active);
  }
);
```

## Sitemap

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