-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(i18n): allow certain simple HTML tags when using Translate compo…
…nent (#5114)
- Loading branch information
Showing
6 changed files
with
171 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
import {Translate, useTranslation} from 'sanity' | ||
import React from 'react' | ||
import {Card, Text} from '@sanity/ui' | ||
import {Card, Stack, Text} from '@sanity/ui' | ||
import {InfoFilledIcon} from '@sanity/icons' | ||
|
||
export function TranslateExample() { | ||
const {t} = useTranslation('testStudio') | ||
return ( | ||
<Card padding={4}> | ||
<Text> | ||
<Translate | ||
t={t} | ||
i18nKey="translate.example" | ||
components={{ | ||
Icon: () => <InfoFilledIcon />, | ||
Red: ({children}) => <span style={{color: 'red'}}>{children}</span>, | ||
Bold: ({children}) => <b>{children}</b>, | ||
}} | ||
values={{ | ||
keyword: 'something', | ||
duration: '30', | ||
}} | ||
/> | ||
</Text> | ||
<Stack space={4}> | ||
<Text>{t('use-translation.with-html')}</Text> | ||
|
||
<Text> | ||
<Translate t={t} i18nKey="use-translation.with-html" /> | ||
</Text> | ||
|
||
<Text> | ||
<Translate | ||
t={t} | ||
i18nKey="translate.example" | ||
components={{ | ||
Icon: () => <InfoFilledIcon />, | ||
Red: ({children}) => <span style={{color: 'red'}}>{children}</span>, | ||
Bold: ({children}) => <b>{children}</b>, | ||
}} | ||
values={{ | ||
keyword: 'something', | ||
duration: '30', | ||
}} | ||
/> | ||
</Text> | ||
</Stack> | ||
</Card> | ||
) | ||
} |
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
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