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')
         , 'https://toggen.com.au/blog');

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

echo $this->Html->link( 
        __('Hello James', true)
         , 'https://toggen.com.au/blog');

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

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...

Ubuntu on Hyper-v

It boils town to installing linux-azure # as root or sudo apt-get update apt-get install linux-azure...