Skip to content

API Reference / @gtkx/i18n / ReactOptions

Interface: ReactOptions ​

The react options of react-i18next, which fills in this interface (since v27; before, i18next declared them). Without react-i18next in the program, react takes any object.

Properties ​

bindI18n? ​

optional bindI18n?: string | false

Set which events trigger a re-render (useTranslation, withTranslation, Translation, Trans and IcuTrans), can be set to false or string of events

Default ​

ts
'languageChanged'

bindI18nStore? ​

optional bindI18nStore?: string | false

Set which events on store trigger a re-render, can be set to false or string of events

Default ​

ts
''

defaultTransParent? ​

optional defaultTransParent?: string

Set it to the default parent element created by the Trans component.

Default ​

ts
undefined (no parent element)

keyPrefix? ​

optional keyPrefix?: string | (($) => any)

Optional keyPrefix that will be automatically applied to returned t function in useTranslation for example. Accepts a string or a selector function (e.g. $ => $.deeply.nested).

Default ​

ts
undefined

nsMode? ​

optional nsMode?: "default" | "fallback"

Set it to fallback to let passed namespaces to translated hoc act as fallbacks

Default ​

ts
'default'

transDefaultProps? ​

optional transDefaultProps?: object

Default props to apply to all Trans components. Component-level props will override these defaults.

components? ​

optional components?: readonly unknown[] | {[tagName: string]: unknown; }

shouldUnescape? ​

optional shouldUnescape?: boolean

Deprecated ​

ignored: Trans always decodes HTML entities

tOptions? ​

optional tOptions?: TOptions

values? ​

optional values?: object


transEmptyNodeValue? ​

optional transEmptyNodeValue?: string

Set fallback value for Trans components without children

Default ​

ts
undefined

transKeepBasicHtmlNodesFor? ​

optional transKeepBasicHtmlNodesFor?: readonly string[]

Which nodes not to convert in defaultValue generation in the Trans component.

Default ​

ts
['br', 'strong', 'i', 'p']

transSupportBasicHtmlNodes? ​

optional transSupportBasicHtmlNodes?: boolean

Convert eg. <br/> found in translations to a react component of type br

Default ​

ts
true

transWrapTextNodes? ​

optional transWrapTextNodes?: string

Wrap text nodes in a user-specified element.

Default ​

ts
''

useSuspense? ​

optional useSuspense?: boolean

Set it to false if you do not want to use Suspense

Default ​

ts
true

Methods ​

hashTransKey()? ​

optional hashTransKey(defaultValue): unknown

Function to generate an i18nKey from the defaultValue (or Trans children) when no key is provided. By default, the defaultValue (Trans text) itself is used as the key. If you want to require keys for all translations, supply a function that always throws an error.

Parameters ​

defaultValue ​

unknown

Returns ​

unknown

Default ​

ts
undefined

unescape()? ​

optional unescape(str): string

Unescape function, used by Trans to decode the HTML entities in its output by default it unescapes some basic html entities

Parameters ​

str ​

string

Returns ​

string