-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add t function to TransProps types (#969)
* Add t function to TransProps types * Add usage test
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as React from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
function basic() { | ||
return <Trans>Foo</Trans>; | ||
} | ||
|
||
function children() { | ||
return ( | ||
<Trans> | ||
<div /> | ||
</Trans> | ||
); | ||
} | ||
|
||
function components() { | ||
return <Trans components={[<div />]}>Foo</Trans>; | ||
} | ||
|
||
function count() { | ||
return <Trans count={42}>Foo</Trans>; | ||
} | ||
|
||
function defaults() { | ||
return <Trans defaults={'defaults'}>Foo</Trans>; | ||
} | ||
|
||
function i18n() { | ||
const { i18n } = useTranslation(); | ||
return <Trans i18n={i18n}>Foo</Trans>; | ||
} | ||
|
||
function i18nKey() { | ||
return <Trans i18nKey={'i18nKey'}>Foo</Trans>; | ||
} | ||
|
||
function ns() { | ||
return <Trans ns={'ns'}>Foo</Trans>; | ||
} | ||
|
||
function parent() { | ||
return <Trans parent={<div />}>Foo</Trans>; | ||
} | ||
|
||
function tOptions() { | ||
return <Trans tOptions={{}}>Foo</Trans>; | ||
} | ||
|
||
function values() { | ||
return <Trans values={{}}>Foo</Trans>; | ||
} | ||
|
||
function t() { | ||
const { t } = useTranslation(); | ||
return <Trans t={t}>Foo</Trans>; | ||
} |