# gt-next: General Translation Next.js SDK: RuntimeTranslationOptions URL: https://generaltranslation.com/en-GB/docs/next/api/types/runtime-translation-options.mdx --- title: RuntimeTranslationOptions description: API reference for the RuntimeTranslationOptions type --- ## Overview The `RuntimeTranslationOptions` type is used to pass variables to inline translations and specify their rendering behaviour. You can also add a locale to specify a different language for the translation. This is used with the [`tx`](/docs/next/api/strings/tx) function. **Runtime Translation:** To translate a variable on demand, include it directly in the string passed to [`tx`](/docs/next/api/strings/tx). Variables passed to `tx` via the `options` object are not translated. ## Reference ### Parameters ### Description | Prop | Description | | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | | `[variable]` | Variables are passed as top-level keys in the options object. The key names correspond to placeholders in the string (e.g. `{username}`). | | `$locale` | Specify a locale for the translation. Defaults to the browser's most preferred locale supported by your app. | | `$maxChars` | Limit the character count of the translation. The library strictly enforces this limit. | *** ## Examples ### Passing variables To add a variable to the string, use the `{variable-name}` syntax, where curly braces wrap the name of the variable. ```jsx title="Component.tsx" // [!code word:username] import { tx } from 'gt-next/server'; const Component = () => { return
{tx(`Hello, {username}!`,{ username: 'Brian123' })}
; }; ``` ### Using ICU message format `gt-next` supports ICU message format, which also lets you format your variables. ```jsx title="Component.tsx" // [!code word:account-balance] import { tx } from 'gt-next/server'; const Component = () => { return
{ tx( 'Your account balance: {dollars, number, ::currency/USD}!', { "dollars" : 1000000, } ) }
; }; ``` ### Translating variables To translate a variable, include it directly in the string passed to `tx`. ```jsx title="Component.tsx" import { tx } from 'gt-next/server'; const Component = ({ hairColor }: { hairColor: string }) => { return
{tx( `Hello, {username}! Your haircolor is ${hairColor}`, { username: 'Brian123' } )}
; }; ``` Note that the variable `hairColor` gets translated, but `username` does not. ### Specifying a locale You can specify the locale to use for the translation. ```jsx title="Component.tsx" import { tx } from 'gt-next/server'; const Component = () => { return
{tx('Hello, world!', { $locale: 'fr' })}
; }; ``` This will always be translated into French. ### Character limits Use `$maxChars` to limit translation length: ```jsx title="Component.tsx" // [!code word:$maxChars] import { tx } from 'gt-next/server'; const Component = () => { return
{tx('Welcome to our application', { $maxChars: 15 })}
; // Output: "Bienvenue à no\u202F…" }; ``` *** ## Notes * `RuntimeTranslationOptions` is used for translating strings at runtime. * Variables are passed as top-level keys in the options object, not nested under a `variables` key. ## Next steps * See [`tx`](/docs/next/api/strings/tx) for more information on inline string translations. * See [`ICU message format`](https://unicode-org.github.io/icu/userguide/format_parse/messages/) for more information on formatting options.