CakePHP – Do you want the internationalization? You can’t handle the internationalization!

Written by James McDonald

October 10, 2011

Just playing with the HTML Helper link method

Putting __() around a string makes it ready for internationalization in CakePHP. You create a translation file using poedit or somesuch and then CakePHP will automagically replace the contents with the other language when told to.

But discovered you can’t do this:

echo $this->Html->link( 
        __('Hello James')
         , '');

You must add “, true” to tell it to return when it’s not being echoed.

echo $this->Html->link( 
        __('Hello James', true)
         , '');

So if you see dead link text in your CakePHP application which uses __() then check to make sure you use __(‘Your Text’, true).


Submit a Comment

Your email address will not be published.

You May Also Like…

MacOS USB Creator

Just toasted my Windows 10 Pro install with a Windows 11 upgrade. Think it will be unrecoverable (because of Bitlocker...