Tuesday, March 2, 2010

Re: Translating the autogenerates Labels in views?

Under .../app/local/ create de_DE/LC_MESSAGES/ folders
You can use German dialects also http://en.wikipedia.org/wiki/ISO_3166-2:DE
With poedit application create default.po and default.mo under .../ de_DE/LC_MESSAGES/
You can set poedit to reference you code directory and fetch all strings inside __()
Pay attention the poedit default for gettext function is _(), one underscore only, cake use two underscores.
So don't forget to set this value.
After you have all your strings in English you use poedit to translate.

Poedit is your friend now so take the time to learn the application http://www.poedit.net/

In my application I use code that I copied from Agendami project http://sourceforge.net/projects/agendami/

in app_controller place a language function
<code>
function language () {
        $lang = $this -> params['url']['lang'];
        $url = "/".$this -> params['url']['backurl'];
        $this -> Cookie -> write ('language', $lang);
        $this -> redirect ($url);
    }
</code>

in /app/bootstrap.php
<code>
Configure::write('Config.language', 'fr_FR');
</code>

in my default layout I support English, French and Korean.
<code>
<?php $url0=$this-> params['url']['url'];
  $url1 = $html -> url (array ('controller'=>'users','action'=>'language'), true);
  $img = $html -> image ('/img/flags/us.png', array ('alt' => 'USA', 'border' => '0'));
  $url = $url1 . "?lang=eng&backurl=" . $url0;
  e ($html -> link ($img, $url, array ('title' => 'USA'), null, false)." ");
                               
  $img = $html -> image ('/img/flags/ko.png', array ('alt' => 'Korea', 'border' => '0'));
  $url = $url1 . "?lang=ko_KR&backurl=" . $url0;
  e ($html -> link ($img, $url, array ('title' => 'Korea'), null, false)." ");

  $img = $html -> image ('/img/flags/fr.png', array ('alt' => 'French', 'border' => '0'));
  $url = $url1 . "?lang=fr_FR&backurl=" . $url0;
  e ($html -> link ($img, $url, array ('title' => 'French'), null, false)." ");
  ?>
</code>

famfamfam  contain a collection of flag images http://www.famfamfam.com/

I think that all.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: