# General Translation React SDKs (gt-react, gt-next): InlineTranslationOptions URL: https://generaltranslation.com/en-GB/docs/react/reference/types/inline-translation-options.mdx --- title: InlineTranslationOptions description: Options for passing variables and metadata to inline string translations with General Translation gt-react. API reference for InlineTranslationOptions. --- `InlineTranslationOptions` is the options object for inline string translations. It carries interpolation variables as well as metadata such as context and an identifier. It is accepted by [`useGT`](/docs/react/reference/hooks/use-gt) and [`msg`](/docs/react/reference/functions/msg). *These options apply wherever [`useGT`](/docs/react/reference/hooks/use-gt) and [`msg`](/docs/react/reference/functions/msg) are available — `gt-react`, `gt-next`, `gt-tanstack-start`, and `gt-react-native`. The named `GTTranslationOptions` type is exported by `gt-react`, `gt-next`, and `gt-react-native`; `gt-tanstack-start` re-exports the functions but not the type.* ## Overview [#overview] Pass interpolation variables as plain keys, and translation metadata with `$`-prefixed keys. ```typescript type InlineTranslationOptions = { [variable: string]: unknown; // interpolation variables $context?: string; $id?: string; $format?: string; $locale?: string; $maxChars?: number; $requiresReview?: boolean; }; ``` *Note: in `gt-react` v11, this options object is the exported `GTTranslationOptions` type. Variables are inserted into the translation but are never translated themselves.* ## Properties [#properties] | Property | Description | Type | | ------------------------------------- | ---------------------------------------------------- | ------------------------- | | [`variables`](#variables) | Interpolation values, keyed by name. | `Record` | | [`$context`](#context) | Disambiguation context for translators. | `string` | | [`$id`](#id) | Stable entry identifier for the Translation Editor. | `string` | | [`$format`](#format) | The data format for the message (e.g., ICU, STRING). | `string` | | [`$locale`](#locale) | Override the target locale. | `string` | | [`$maxChars`](#max-chars) | Maximum translation length. | `number` | | [`$requiresReview`](#requires-review) | Require human approval before use. | `boolean` | ### `variables` [#variables] **Type** `Record` Any non-`$` key is treated as an interpolation variable. Reference it in the string using `{name}` syntax; its value is inserted into the translated string without itself being translated. ### `$context` [#context] **Type** `string` · **Optional** Context to refine the translation, used to resolve ambiguous phrases. ### `$id` [#id] **Type** `string` · **Optional** A stable identifier for the entry, used with the translation editor. ### `$format` [#format] **Type** `string` · **Optional** · **Default** `ICU` The data format for the message (e.g. ICU, STRING). Defaults to ICU. ### `$locale` [#locale] **Type** `string` · **Optional** Overrides the target locale for this translation. ### `$maxChars` [#max-chars] **Type** `number` · **Optional** Limits the character count of the translation. The library enforces this limit. ### `$requiresReview` [#requires-review] **Type** `boolean` · **Optional** When `true`, marks the translation as requiring human approval before it is used. ## Examples [#examples] ```tsx title="Component.tsx" import { useGT } from 'gt-react'; const Component = () => { const gt = useGT(); return
{gt('Hello, world!', { $context: 'a formal greeting' })}
; }; ``` ```tsx title="Component.tsx" import { useGT } from 'gt-react'; const Component = () => { const gt = useGT(); return
{gt('Hello, {username}! How is your day?', { username: 'Brian123' })}
; }; ``` ```tsx title="Component.tsx" import { useGT } from 'gt-react'; // ICU message format formats variables const Component = () => { const gt = useGT(); return (
{gt('Your account balance: {dollars, number, ::currency/USD}!', { dollars: 1000000 })}
); }; ``` ```tsx title="Component.tsx" import { useGT } from 'gt-react'; const Component = () => { const gt = useGT(); return
{gt('Welcome to our application', { $maxChars: 15 })}
; }; ``` `gt-react` supports [ICU message format](https://unicode-org.github.io/icu/userguide/format_parse/messages/) for formatting variables. ## Notes [#notes] * `InlineTranslationOptions` is used with [`useGT`](/docs/react/reference/hooks/use-gt) and [`msg`](/docs/react/reference/functions/msg). * For dictionary lookups, see [`DictionaryTranslationOptions`](/docs/react/reference/types/dictionary-translation-options).