Interpolate (v9)
Deprecated: We highly recommend having a look at the new trans component as it provides a better experience.
This component will be remove in the next major version v9.0.0!!
The interpolate component enables you to interpolate react components into translation strings (eg. to use links).
the key:
sample:
You can use formatting as in i18next.
props:
i18nKey: the key to lookup
options: options to use for translation (exclude interpolation variables!)
parent: optional component to wrap translation into (default 'span')
useDangerouslySetInnerHTML: allows use of raw html tags in translation values
dangerouslySetInnerHTMLPartElement: optional component to wrap parts of translation values into (default 'span'), used with
useDangerouslySetInnerHTML={true}
onlyi18n: i18next instance to use if not provided via context (using hoc or render props)
t: t function to use if not provided via context (using hoc or render props)
...props: values to interpolate into found translation (eg.
my value with {{replaceMe}} interpolation
)
using useDangerouslySetInnerHtml
Allows having html tags inside the translation with a restriction as those get wrapped in spans. You can't have a interpolation value inside a html tag.
the key:
sample:
Alternatives
a) Use standard interpolation of i18next and dangerously insert that:
b) use markdown, eg. react-remarkable and pass markdown formatted content from translations to the markdown component.
Last updated