我必须做网站的SEO,我使用了Symfony Translations,并且我想知道如何在本示例中使用TWIG在“关键字”中添加一个强标记:
<p>{{ "This text has keywords" |trans }}</p>
我已经尝试过了,但是没有用:
<p>{{ "This text has "<strong>"**keywords**"</strong> |trans }}</p>
谢谢!
您好,您有更多关于这个问题的解决方案,这些是我的解决方案:
您认为:
<!-- solution 1 only string -->
{{ 'solution1'|trans|raw }}
<!-- solution 2 with variable -->
{% trans with {'%{name}': app.user.name} %}solution2{% endtrans %}
在您的messages.en.xlf中
<trans-unit id="6Koj_Rn" resname="solution1">
<source>solution1</source>
<target><![CDATA[Hello <strong>test</strong>]]></target>
</trans-unit>
<trans-unit id="AvMFbMR" resname="solution2">
<source>solution2</source>
<target><![CDATA[Hello <strong>%{name}</strong>]]></target>
</trans-unit>