Cakephp:将链接添加到echo中
问题描述:
I have such a line of code
<?php echo __('This is text and the word TEXT has to be a link'); ?>
Is there any good trick to link the word "TEXT" to another href address? maybe without changing the entire structure? As I am using the i18n translation as the website is using 3 languages I want to keep the changes as minimal as possible.
Thanks in advance!
我有这样一行代码 p>
&lt;? php echo __('这是文本,TEXT一词必须是链接'); ?&gt;
code> pre>
有没有什么好的技巧可以将“TEXT”这个词链接到另一个href地址? 也许没有改变整个结构? 由于我使用i18n翻译,因为网站使用3种语言,我希望尽可能减少更改。 p>
提前致谢! p>
div>
答
You could try to pass your link as an argument to __() function:
<?= __('This is text and the word {0} has to be a link', $this->Html->link(...)) ?>
More info can be found here: https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#using-variables-in-translation-messages