这个周末我正在做一个叫“海盗大战”的小项目。忍者Vs。僵尸Vs。机器人;)
目的是学习Cake的一些我以前还没有用过的方面--比如用于翻译的__()函数。
我得到了一条消息,我想输出类似于“%s谢谢你”的消息,其中%s将是“僵尸”。如果我使用的是普通的PHP,我想我会使用:
$string = 'Zombies';
printf('The %s thank you', $string);但是,当我尝试使用__() translate函数时,我不知道如何工作。
有谁能帮帮我吗?谢谢您:)
发布于 2011-01-22 23:09:40
将__函数的第二个参数设置为true,它将返回翻译后的字符串,而不是回显:
$string = 'Zombies';
printf(__('The %s thank you', true), $string);发布于 2012-03-06 23:05:11
在cakephp 2.0+中,默认情况下会进行翻译
$string = 'Zombies';
echo __('The %s thank you', $string);https://stackoverflow.com/questions/4768350
复制相似问题