如何使用gatsby使用I18N使用文本格式(粗体,斜体等)?
我正在使用gatsby-plugin-react-i18next来翻译我的网站,并且可以使用简单的文本。但是,当我尝试使用大胆文本或斜体文本格式化文本的部分时,它不起作用(我不知道该怎么做)。
如何使用I18N格式化段落的特定部分?
以下是我设置的一个示例。
Page JS
const IndexPage = () => {
const { t } = useTranslation();
return (
<Layout>
<Seo title="Home" />
<div>
<h1>
{t("HomepageHeader")}
</h1>
<p>
{t("HomepageDescription")}
</p>
</div>
</Layout>
)
}
export default IndexPage
文件夹结构:
locales
-en
-translation.json
-nl -nl
-translation.json
示例json en
{
"HomepageHeader": "Grow your business with a modern website!",
"HomepageDescription": "Your website is the number 1 selling point, to your customers. Make sure you get the most out of it!"
}
我如何做 HomePagedEscription Bold仅“ 1号卖点”?
I'm using gatsby-plugin-react-i18next for translating my website, and it works with simple text. But when I try to format parts of the text, with bold text or italic text, it doesn't work (I don't know how to do it).
How can I format a specific part of a paragraph using i18n?
Below is an example of my setup.
page JS
const IndexPage = () => {
const { t } = useTranslation();
return (
<Layout>
<Seo title="Home" />
<div>
<h1>
{t("HomepageHeader")}
</h1>
<p>
{t("HomepageDescription")}
</p>
</div>
</Layout>
)
}
export default IndexPage
Folder structure:
locales
-en
--translation.json
-nl
--translation.json
Example JSON en
{
"HomepageHeader": "Grow your business with a modern website!",
"HomepageDescription": "Your website is the number 1 selling point, to your customers. Make sure you get the most out of it!"
}
How can I make for example only "number 1 selling point" in the HomepageDescription bold?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看trans组件: https://react.i18next.com/latest com.com/latest/latest/latest/trans-trans-trans-trans-trans-trans-trans-trans-in,组件
或使用Markdown组件,类似:
Have a look at the Trans Component: https://react.i18next.com/latest/trans-component
Or use a markdown component, something like: