Trans.md
January 8, 2019 · View on GitHub
A render-prop that provides Universal Interface.
It provides an object with translation function t and translation state T.
<Trans>{({t, T}) =>
{t('Hello')}, user! {t('welcome')}
<br />
<button onClick={() => T.setLocale('en')}>en</button>
<button onClick={() => T.setLocale('fr')}>fr</button>
}</Trans>
It also accepts pure strings.
<Trans>Hello</Trans>
Or a mix of strings and functions.
<Trans>{t => t('Hello')}!</Trans>
Props
ns— a namespace or an array of namespaces, defaults to'main'.