Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 791 Bytes

Trans.md

File metadata and controls

32 lines (22 loc) · 791 Bytes

<Trans>

React Universal Interface

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'.