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?
optionalbindI18n?: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
'languageChanged'bindI18nStore?
optionalbindI18nStore?:string|false
Set which events on store trigger a re-render, can be set to false or string of events
Default
''defaultTransParent?
optionaldefaultTransParent?:string
Set it to the default parent element created by the Trans component.
Default
undefined (no parent element)keyPrefix?
optionalkeyPrefix?: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
undefinednsMode?
optionalnsMode?:"default"|"fallback"
Set it to fallback to let passed namespaces to translated hoc act as fallbacks
Default
'default'transDefaultProps?
optionaltransDefaultProps?:object
Default props to apply to all Trans components. Component-level props will override these defaults.
components?
optionalcomponents?: readonlyunknown[] | {[tagName:string]:unknown; }
shouldUnescape?
optionalshouldUnescape?:boolean
Deprecated
ignored: Trans always decodes HTML entities
tOptions?
optionaltOptions?:TOptions
values?
optionalvalues?:object
transEmptyNodeValue?
optionaltransEmptyNodeValue?:string
Set fallback value for Trans components without children
Default
undefinedtransKeepBasicHtmlNodesFor?
optionaltransKeepBasicHtmlNodesFor?: readonlystring[]
Which nodes not to convert in defaultValue generation in the Trans component.
Default
['br', 'strong', 'i', 'p']transSupportBasicHtmlNodes?
optionaltransSupportBasicHtmlNodes?:boolean
Convert eg. <br/> found in translations to a react component of type br
Default
truetransWrapTextNodes?
optionaltransWrapTextNodes?:string
Wrap text nodes in a user-specified element.
Default
''useSuspense?
optionaluseSuspense?:boolean
Set it to false if you do not want to use Suspense
Default
trueMethods
hashTransKey()?
optionalhashTransKey(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
undefinedunescape()?
optionalunescape(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