[使用Symfony Translations时如何在TWIG中为SEO添加标签? [关闭]

问题描述 投票:-3回答:1

我必须做网站的SEO,我使用了Symfony Translations,并且我想知道如何在本示例中使用TWIG在“关键字”中添加一个强标记:

<p>{{ "This text has keywords" |trans }}</p>

我已经尝试过了,但是没有用:

<p>{{ "This text has "<strong>"**keywords**"</strong> |trans }}</p>

谢谢!

php html symfony twig
1个回答
0
投票

您好,您有更多关于这个问题的解决方案,这些是我的解决方案:

您认为:

<!-- 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&ensp;<strong>test</strong>]]></target>
</trans-unit>

<trans-unit id="AvMFbMR" resname="solution2">
  <source>solution2</source>
  <target><![CDATA[Hello&ensp;<strong>%{name}</strong>]]></target>
</trans-unit>
© www.soinside.com 2019 - 2024. All rights reserved.