-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-i18n): interpolate JSX tags inside translations (#22)
Add the ability to interpolate JSX inside translations.
- Loading branch information
Showing
6 changed files
with
376 additions
and
20 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
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
95 changes: 95 additions & 0 deletions
95
packages/react-i18n/src/utils/__tests__/__snapshots__/i18n.utils.spec.js.snap
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,95 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`i18n translate function with JSX should not try to interpolate basic html tag 1`] = ` | ||
<div> | ||
<em>Hello</em> <strong>Moto</strong> ! | ||
</div> | ||
`; | ||
|
||
exports[`i18n translate function with JSX should render a complex JSX structure inside the translation 1`] = ` | ||
<div> | ||
<Bold> | ||
<strong> | ||
<Italic> | ||
<em> | ||
Hell | ||
</em> | ||
</Italic> | ||
o | ||
</strong> | ||
</Bold> | ||
<LineBreak> | ||
<br /> | ||
</LineBreak> | ||
Moto | ||
<LineBreak> | ||
<br /> | ||
</LineBreak> | ||
! | ||
</div> | ||
`; | ||
|
||
exports[`i18n translate function with JSX should render the JSX component and sibling JSX component present inside the translation 1`] = ` | ||
<div> | ||
<Italic> | ||
<em> | ||
Hello | ||
</em> | ||
</Italic> | ||
<Bold> | ||
<strong> | ||
Moto | ||
</strong> | ||
</Bold> | ||
! | ||
</div> | ||
`; | ||
|
||
exports[`i18n translate function with JSX should render the JSX component present inside the translation 1`] = ` | ||
<div> | ||
Hello | ||
<Bold> | ||
<strong> | ||
Moto | ||
</strong> | ||
</Bold> | ||
! | ||
</div> | ||
`; | ||
|
||
exports[`i18n translate function with JSX should render the nested JSX component present inside the translation 1`] = ` | ||
<div> | ||
Hello | ||
<Bold> | ||
<strong> | ||
<Italic> | ||
<em> | ||
Moto | ||
</em> | ||
</Italic> | ||
</strong> | ||
</Bold> | ||
! | ||
</div> | ||
`; | ||
|
||
exports[`i18n translate function with JSX should render the short (without children) JSX component inside the translation 1`] = ` | ||
<div> | ||
Hello | ||
<LineBreak> | ||
<br /> | ||
</LineBreak> | ||
Moto | ||
<LineBreak> | ||
<br /> | ||
</LineBreak> | ||
! | ||
</div> | ||
`; | ||
|
||
exports[`i18n translate function with JSX should works with badly formatted JSX 1`] = ` | ||
<div> | ||
<Bold>Toto</Italic> | ||
</div> | ||
`; |
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
Oops, something went wrong.