我正在与 i18next 合作进行反应 https://github.com/i18next/react-i18next 。我正在努力在我的 JSON 语言文件中的字符串中换行。
这是我已经尝试过的,不会换行:
line: "This is a line. \n This is another line. \n Yet another line"
,line: ("This is a line."+ <br/> + "This is another line. \n Yet another line")
,line: ('This is a line. <br/> This is another line. \n Yet another line')
,
我显然试图在每个句子后换行。我就是这样称呼它的:
<TooltipLink onClick={() => {
this.toggleHelpTextDialog(t('test:test.line'));
}}/>
有任何想法吗?谢谢!
原文由 Nocebo 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以在翻译文本中使用 css
white-space: pre-line;
&\n
来完成。