# General Translation React SDKs (gt-react, gt-next, gt-react-native): InlineTranslationOptions
URL: https://generaltranslation.com/ja/docs/react/reference/types/inline-translation-options.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: インライン文字列翻訳に変数とメタデータを渡すためのオプションです。InlineTranslationOptions の API リファレンス。

`InlineTranslationOptions` は、インライン文字列翻訳用のオプションオブジェクトです。補間変数に加え、コンテキスト や識別子などのメタデータを保持します。[`useGT`](/docs/react/reference/hooks/use-gt) と [`msg`](/docs/react/reference/functions/msg) で使用できます。

*[`useGT`](/docs/react/reference/hooks/use-gt) と [`msg`](/docs/react/reference/functions/msg) が利用できる環境であれば、これらのオプションはどこでも適用されます — `gt-react`、`gt-next`、`gt-tanstack-start`、`gt-react-native`。`GTTranslationOptions` という名前の型は `gt-react`、`gt-next`、`gt-react-native` から export されますが、`gt-tanstack-start` は関数を再エクスポートするものの、型は再エクスポートしません。*

## 概要 [#overview]

補間変数は通常のキーとして、翻訳メタデータは `$` プレフィックス付きのキーとして渡します。

```typescript
type InlineTranslationOptions = {
  [variable: string]: unknown; // 補間変数
  $context?: string;
  $id?: string;
  $format?: string;
  $locale?: string;
  $maxChars?: number;
  $requiresReview?: boolean;
};
```

*注: `gt-react` v11 では、この オプションオブジェクト はエクスポートされる `GTTranslationOptions` 型です。変数は翻訳に挿入されますが、変数自体が翻訳されることはありません。*

## プロパティ [#properties]

| プロパティ                                 | 説明                            | 型                         |
| ------------------------------------- | ----------------------------- | ------------------------- |
| [`variables`](#variables)             | 名前をキーにした補間値。                  | `Record<string, unknown>` |
| [`$context`](#context)                | 翻訳者向けの曖昧さ回避用コンテキスト。           | `string`                  |
| [`$id`](#id)                          | 翻訳エディター用の固定エントリ識別子。           | `string`                  |
| [`$format`](#format)                  | メッセージのデータ形式 (例: ICU、STRING) 。 | `string`                  |
| [`$locale`](#locale)                  | 対象ロケールを上書きします。                | `string`                  |
| [`$maxChars`](#max-chars)             | 生成された翻訳に要求される最大文字数。           | `number`                  |
| [`$requiresReview`](#requires-review) | 使用前に人の承認を必須にします。              | `boolean`                 |

### `variables` [#variables]

**型** `Record<string, unknown>`

`$` 以外の任意のキーは補間変数として扱われます。文字列内で `{name}` 構文を使って参照すると、その値は翻訳されずに翻訳後の文字列に挿入されます。

### `$context` [#context]

**型** `string` · **任意**

翻訳の精度を高めるための補足情報で、あいまいな表現の意味を明確にするために使用されます。

### `$id` [#id]

**型** `string` · **任意**

翻訳エディターで使用する、エントリの安定した識別子です。

### `$format` [#format]

**型** `string` · **任意** · **デフォルト** `ICU`

メッセージのデータ形式を指定します (例: ICU、STRING) 。デフォルトは ICU です。

### `$locale` [#locale]

**型** `string` · **任意**

この翻訳で使用する対象ロケールを上書きします。

### `$maxChars` [#max-chars]

**型** `number` · **任意**

翻訳ツールに正の整数の最大文字数を指定します。読み込まれた翻訳がこの上限を超える場合、文字列補間時にもランタイムで切り詰めが適用されます。

### `$requiresReview` [#requires-review]

**型** `boolean` · **任意**

`true` の場合、この翻訳は使用前に人による承認が必要としてマークされます。

## 例 [#examples]

```tsx title="Component.tsx"
import { useGT } from 'gt-react';

const Component = () => {
  const gt = useGT();
  return <div>{gt('Hello, world!', { $context: 'a formal greeting' })}</div>;
};
```

```tsx title="Component.tsx"
import { useGT } from 'gt-react';

const Component = () => {
  const gt = useGT();
  return <div>{gt('Hello, {username}! How is your day?', { username: 'Brian123' })}</div>;
};
```

```tsx title="Component.tsx"
import { useGT } from 'gt-react';

// ICU message formatで変数をフォーマットする
const Component = () => {
  const gt = useGT();
  return (
    <div>
      {gt('Your account balance: {dollars, number, ::currency/USD}!', { dollars: 1000000 })}
    </div>
  );
};
```

```tsx title="Component.tsx"
import { useGT } from 'gt-react';

const Component = () => {
  const gt = useGT();
  return <div>{gt('Welcome to our application', { $maxChars: 15 })}</div>;
};
```

`gt-react` は、変数のフォーマットに [ICU message format](https://unicode-org.github.io/icu/userguide/format_parse/messages/) をサポートしています。

## メモ [#notes]

* `InlineTranslationOptions` は [`useGT`](/docs/react/reference/hooks/use-gt) および [`msg`](/docs/react/reference/functions/msg) と併せて使用します。
* 辞書の参照については、[`DictionaryTranslationOptions`](/docs/react/reference/types/dictionary-translation-options) をご覧ください。

## Sitemap

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