开发者

Passing variables to the __() function in CakePHP

I'm in the process of building a little project this weekend called Pirates Vs. Ninjas Vs. Zombies Vs. Robots ;)

The purpose is to learn some of the aspects of Cake that I've not yet used before - such as the __() function for translation.

I've got a message that I want to output along the lines of "The %s thank you", where %s would be 'Zombies'. If I was using normal PHP, I guess I would use:

$string = 'Zombies';
printf('The %s thank you', $string);

But as I'm trying to use the __() translate function, I don't know how to mak开发者_运维技巧e this work.

Can anyone help me please? Thank you :)


in cakephp 2.0+ it translates by default

$string = 'Zombies';
echo __('The %s thank you', $string);


Set the second parameter of the __ function to true and it will return the translated string instead of echoing it:

$string = 'Zombies';
printf(__('The %s thank you', true), $string);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜