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 make 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With