It is __(); notice the double underscore. -- /** * @author Larry E. Masters * @var string $userName * @param string $realName * @returns string aka PhpNut * @access public */
On Mon, Aug 17, 2009 at 3:52 PM, RhythmicDevil <rhythmicde...@gmail.com>wrote: > > Hi, > I am trying to understand how to get internationalization to work in > CakePHP. After reading the docs and searching around, looking at > Teknoid and some other place this is what I am left with. > > CakePHP has a class I18n that handles the loading of the correct > string from a .po file based upon the language locale setting. > > CakePHP has a console app that supposedly will read all the strings in > your view files and create language files for you. > > I wrap my string ids in _() which will return the msg for that id. > > I can use POEdit to create my files. > > > Given that. I created one message and placed it in the default.po file > for English. I then used the translator function for the heading on my > login page. However when I start the app it simply fails and tells me > that _() is an undefined function. > > Here is the content of my controller: > > class SubscribersController extends Controller > { > public $helpers = array ('Form', 'Html', 'Javascript'); > public $components = array ('DataPrep'); > > public $SubscriberId = null; > > public function login() > { > $this->pageTitle = 'Please Login'; > $this->layout = 'login'; > $this->SubscriberId = $this->params['data']['Subscriber'] > ['SubscriberId']; > $this->log('Login attempt with SubscriberId: '.$this- > >SubscriberId, Configure::read('APP_LOG')); > $subscriber = $this->Subscriber->QuerySub($this- > >SubscriberId); > if ($subscriber->resultCode == 0) > { > $this->Session->write('Subscriber', $subscriber- > >querySubRsp); > //debug($this->Session->read('Subscriber')); > $this->redirect( array ('controller'=>'subscribers', > 'action'=>'basics')); > } > > } > ............ > > Here is the content of my View file: > > <div class="grid_6"> </div> > <div class="grid_4" style="margin-top:200px; background:#FFF;"> > <div style="text-align:center; font-weight:bold;"><?php > _("Please > Login"); ?></div> > <div style="padding:20px;"> > > <?php > echo $form->create($options = array('action' => > 'login')); > echo $form->input('Subscriber.SubscriberId'); > echo $form->button('Login', array('type'=>'submit', > 'class'=>'button')); > echo $form->end(); > ?> > </div> > </div> > <div class="grid_6"> </div> > > > Here is the content of my default.po file that is in the directory / > app/locale/eng/LC_MESSAGES/ > > msgid "" > msgstr "" > "Project-Id-Version: \n" > "POT-Creation-Date: \n" > "PO-Revision-Date: \n" > "Last-Translator: Steven Wright <swri...@etisoftware.com>\n" > "Language-Team: \n" > "MIME-Version: 1.0\n" > "Content-Type: text/plain; charset=iso-8859-1\n" > "Content-Transfer-Encoding: 8bit\n" > > msgid "Please Login" > msgstr "Please Login" > > > > 1) I am assuming I need to tell Cake to use I18n. But how? Is it a > component, a helper? > 2) Does my .po file look correct? > 3) Am I on the right path? > > Thanks > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---