PHP: What does __('Some text') do?

Reading about Kohana templates and saw something I've never seen before:

$this->template->title = __('Welcome To Acme Widgets');

What does __('Text') mean? What is it? What does it do?


In Kohana (version 3) the function is defined in system/base.php and is a convenience function to aid (as the other answers have mentioned) internationalization. You provide a string (with, optionally, some placeholders to substitute values into the finished text) which is then interpreted and, if required, a translation is returned.

Contrary to assumptions in other answers, this does not use gettext.

A very basic example would be (this particular string is already translated into English, Spanish and French in Kohana):

// 1. In your bootstrap.php somewhere below the Kohana::init line
I18n::lang('fr');

// 2. In a view
echo __("Hello, world!"); // Bonjour, monde!

The double '__' is used for Localization in CakePHP (and possible other frameworks)

http://book.cakephp.org/view/163/Localization-in-CakePHP


It means someone created a function named __ (That's two underscores next to one another.)

My guess is it defined somewhere in the Kohana documentation.