du kannst natürlich die ganze language sache statt in den
pages_controller.php in dein app_controller.php reinhauen ich hab das nicht
gebraucht deswegen nur in dem controller

Am 25. Juli 2011 20:46 schrieb gloop <[email protected]>:

> Danke ich werde das morgen mal ausprobieren.
>
> LG Steffen
>
> On 25 Jul., 20:25, Davor Ilic <[email protected]> wrote:
> > du brauchst nur die $pageLang varibale die unteren sind special languages
> > für die überstungen von widgets wie facebook und co
> >
> > 2011/7/25 Davor Ilic <[email protected]>
> >
> >
> >
> >
> >
> >
> >
> > > ok zuerst definiere im router deine lang parameter.
> > > ich hab folgendes:
> >
> > >  Router::connect('/:lang',
> > > array('controller'=>'pages','action'=>'index'));
> > >  Router::connect('/:lang/:controller/:action/*', array('controller' =>
> > > 'pages', 'action' => 'index'));
> >
> > > dann tue ich hardcoded in meinem controller den paramter rausnehmen und
> > > mache dies hier im 'pages_controller.php' :
> >
> > >  function language() {
> > >         if(!isset($this->params['lang']) &&
> empty($this->params['lang']))
> > > {
> > >          $lang = explode('-', $_SERVER['HTTP_ACCEPT_LANGUAGE']); //
> hier
> > > setze ich fest welche spache der user schon vorgewählt hat um im schon
> auf
> > > die richtige language zu lotzen
> > >          $language = array('lang'=>$lang[0]);
> >
> > >         }else{
> > >          $language = array('lang' => $this->params['lang']);
> > >         }
> >
> > >         switch($language['lang']) {
> >
> > >        case 'de':
> > >        $pageLang = 'de';
> > >        $spLang = 'de_DE';
> > >        break;
> > >        case 'en':
> > >        $pageLang = 'en';
> > >        $spLang = 'en_US';
> > >        break;
> >
> > >        default:
> > >        $pageLang = 'de';
> > >        $spLang = 'de_DE';
> > >        break;
> > >        }
> >
> > >        $this->params['splang'] = $spLang;
> >
> > >        return $this->params['lang'] = $pageLang;
> > >  }
> >
> > > das wäre dann die methode die ich dann in meinem beforefilter
> reinschmeße:
> >
> > >  function beforefilter() {
> > >         parent::beforeFilter();
> > >  $this->language();//Sprachausgabe nur in en und de derzeit moeglich
> > >  $this->set('home', $this->Setting->field('set_kat_id'));
> > >  if($this->language()=='en') {// hier lege ich fest welche default.po
> er
> > > wählen soll eng oder ger
> > > $translate = 'eng';
> > >  }else{
> > > $translate = 'ger';// ger habe ich nicht eingespeist das heißt wenn er
> > > nichts findet verwendet er normal __('Senden') anstelle noch extra eine
> > > translate file anzugeben weil es eben nicht nötig ist
> > >  }
> > >        Configure::write('Config.language', $translate);
> >
> > >        $this->Session->write('Config.language', $translate);// hier
> lege
> > > ich fest dann welche sprache gewählt wurde und speichere sie in einer
> > > session das er auch vortlaufend die sprache beibehält ist etwas
> > > optimierungswürdig aber hatte keine zeit bisher
> > >  }
> >
> > > und mein folder wo die '.po' ist sieht folgendermaßen aus:
> >
> > > - /app
> > >  -- /locale
> > >   --- /eng
> > >     ---- /LC_MESSAGES
> > >        -- /default.po
> >
> > > wie du siehst habe ich keinen ger ordner aber falls ich es mal brauche
> habe
> > > ich es schon so voreingestellt
> > > und in der default.po kommt dann deine übersetzung rein
> >
> > > msgid  "Anfrage Senden"
> > > msgstr "Send request"
> >
> > > bei mir ist halt die sprache die ich brauche eingestellt vom user
> abhängig
> >
> > > hoffe das hilft dir
> >
> > > 2011/7/25 gloop <[email protected]>
> >
> > >> Im from germany ;)
> >
> > >> Die englische übersetzung klappt, aber auch nur, weil englisch die
> > >> voreinstellung von cake php ist.
> >
> > >> mit __('id', true); klappt es nicht, aber ich habe auch gelesen, dass
> > >> dies für die rückgabe einer variable ist und nicht die ausgabe direkt.
> >
> > >> Configure::write('Config.language', 'de');  << das funktioniert leider
> > >> nicht.
> >
> > >> On 25 Jul., 19:18, Davor Ilic <[email protected]> wrote:
> > >> > in your default.po you write this
> >
> > >> > msgid  "Anfrage Senden"
> > >> > msgstr "Send request"
> >
> > >> > and with the gloabl func __('Anfrage Senden', true);
> >
> > >> > be sure to write it corectly or your translate won´t work
> >
> > >> > or did you mean some other stuff
> >
> > >> > where you from? i´m from austria... if it´s easier for you to write
> in
> > >> > german then do this please it´s also for me  easier :D
> >
> > >> > 2011/7/25 gloop <[email protected]>
> >
> > >> > > OH i try it again and with Configure::write('Config.language',
> 'en');
> > >> > > it works fine!
> >
> > >> > > How can i include the german language?
> >
> > >> > > On 25 Jul., 17:03, Davor Ilic <[email protected]> wrote:
> > >> > > > i´ve use it like that __('test', true);
> >
> > >> > > > but also you have to define some vars to switch did from en to
> other
> > >> lang
> > >> > > > you?
> >
> > >> > > > 2011/7/25 gloop <[email protected]>
> >
> > >> > > > > Hello,
> >
> > >> > > > > i search a whole time in the web for multilanguage in CakePHP.
> I
> > >> found
> > >> > > > > that must create a folder in /app/locale/deu/LC_MESSAGE with a
> > >> file
> > >> > > > > default.po. These musst filled with:
> >
> > >> > > > > msgid "test"
> > >> > > > > msgstr "here the text"
> >
> > >> > > > > that could use in the *.ctp with:
> >
> > >> > > > >    <?php __('test');?>
> >
> > >> > > > > if the entry not found it would write "test".
> >
> > >> > > > > Default is in CakePHP "en".
> >
> > >> > > > > Now i've write in /app/locale/eng/LC_MESSAGE/default.po for
> > >> testing
> > >> > > > > the same text like in the german version, but it writes always
> the
> > >> > > > > "msgid".
> >
> > >> > > > > I've never managed to write the "msgstr".
> >
> > >> > > > > Can anyone help me with my problem :(
> >
> > >> > > > > Kind regards
> > >> > > > > gloop
> >
> > >> > > > > --
> > >> > > > > Our newest site for the community: CakePHP Video Tutorials
> > >> > > > >http://tv.cakephp.org
> > >> > > > > Check out the new CakePHP Questions
> > >> sitehttp://ask.cakephp.organdhelp
> > >> > > > > others with their CakePHP related questions.
> >
> > >> > > > > To unsubscribe from this group, send email to
> > >> > > > > [email protected] For more options, visit
> > >> this
> > >> > > group
> > >> > > > > athttp://groups.google.com/group/cake-php
> >
> > >> > > --
> > >> > > Our newest site for the community: CakePHP Video Tutorials
> > >> > >http://tv.cakephp.org
> > >> > > Check out the new CakePHP Questions
> sitehttp://ask.cakephp.organdhelp
> > >> > > others with their CakePHP related questions.
> >
> > >> > > To unsubscribe from this group, send email to
> > >> > > [email protected] For more options, visit
> this
> > >> group
> > >> > > athttp://groups.google.com/group/cake-php
> >
> > >> --
> > >> Our newest site for the community: CakePHP Video Tutorials
> > >>http://tv.cakephp.org
> > >> Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > >> others with their CakePHP related questions.
> >
> > >> To unsubscribe from this group, send email to
> > >> [email protected] For more options, visit this
> group
> > >> athttp://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to