9

I thought double underscore always meant private function but what does it mean in cakephp 2.0 in such examples as this http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

For example

$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
Tim
  • 14,447
  • 6
  • 40
  • 63
CodeCrack
  • 5,253
  • 11
  • 44
  • 72
  • Cake isn't the only framework/platform to use `__()` as a translate/locale function http://stackoverflow.com/questions/1777131/double-underscore-in-php/1777141#1777141 – Mike B Feb 16 '12 at 22:05
  • Voted down for lack of research. – luchomolina Feb 17 '12 at 13:44
  • 3
    I'm just starting with Cake and didn't realize the double-underscore was a locale thing. Googling "PHP double underscore" talks about magic functions or something, but searching "cakephp double underscore" leads me to your question and Mike B's answer. Thanks for asking this question and ignoring luchomilina. – drug_user841417 Jan 03 '13 at 20:47

1 Answers1

14

The double underscore function in CakePHP handles localization. It's used when you want to translate your application by providing a string translation dictionary.

Cake PHP Book: Global Constants & Functions

See also Internationalization and Localization

Tim
  • 14,447
  • 6
  • 40
  • 63