嗨,对不起我的英语
我尝试在 Symfony/Twig
中插入一个 <a>
标记的翻译文本,但它不被 Symfony
接受,无论我使用 | raw
或 | e
以及 {{ 1}} 过滤器。
肯定有一种方法允许它,但我找不到它。有人可以帮我吗?
提前谢谢
米。
答案 0 :(得分:0)
在 xlf/xml 中添加 html 的方法是使用 。
messages.fr.xlf
<trans-unit id="jumbotron.5">
<source>jumbotron.5</source>
<target>n cas de problème, nous sommes sur <![CDATA[<a href="https://github.com/CRLbazin/agoraexmachina">github</a>]]></target>
</trans-unit>
要在树枝中渲染翻译,请使用 raw filter。
template.html.twig
{{ 'jumbotron.5'|trans|raw }}
对于 symfony,您也可以使用 yaml 文件。看看https://symfony.com/doc/current/translation.html
~/translations/messages.fr.yaml
jumbotron.5: "n cas de problème, nous sommes sur <a href=\"https://github.com/CRLbazin/agoraexmachina\">github</a>"