# General Translation React SDKs (gt-react, gt-next): tx URL: https://generaltranslation.com/ja/docs/react/nextjs/reference/functions/tx.mdx --- title: tx description: General Translation を使用して、Next.js App Router のサーバーコードでリクエスト時の文字列を翻訳します。tx の API リファレンス。 --- `tx` 関数は、General Translation API を介してリクエスト時に文字列を翻訳します。build time では不明な動的コンテンツに使用し、静的な ソース文字列 には [`getGT`](/docs/react/nextjs/reference/functions/get-gt) を使用してください。 `tx` はサーバー専用で、Pages Router では動作しません。 ## 概要 [#overview] ```tsx import { tx } from 'gt-next/server'; const translated = await tx('A message loaded at request time'); ``` ## パラメータ [#parameters] | パラメータ | 説明 | 型 | 任意 | デフォルト | | --------- | ---------------------------- | -------- | --- | ----- | | `message` | 翻訳する文字列。 | `string` | いいえ | — | | `options` | 対象ロケール、コンテキスト、形式、文字数上限、補間変数。 | `object` | はい | `{}` | `options` には `$locale`、`$context`、`$maxChars`、`$format` を指定できます。補間変数はトップレベルのキーとして渡してください。 ## 戻り値 [#returns] **型** `Promise` 翻訳後の文字列を返す Promise です。翻訳が無効、または不要な場合は、ソース文字列を返します。 ## 例 [#example] ```tsx title="app/notes/[id]/page.tsx" import { tx } from 'gt-next/server'; export default async function NotePage({ params }) { const note = await loadNote((await params).id); const translated = await tx(note, { $context: 'A user-created note', }); return

{translated}

; } ```