In my Layout/default.ctp I do something like:

$url =  
> join('/',array($this->params['controller'],$this->params['action'],join('/',$this->params['pass'])));
> echo $this->Html->link('GR','/ell/'.$url).  ' | ' . 
> $this->Html->link('EN','/eng/' . $url) ;
>

and seems to work.

I hade the same problem with you that's why I ended up in this solution.


On Tuesday, May 13, 2014 2:40:55 PM UTC+3, Lorenzo Milesi wrote:
>
> Hi.
> I localized my app using [1] and [2] and works fine, but I'm having 
> problem with the language switcher and page views.
> In my top menu I have the following items:
> echo $this->Html->link(__('Knowledge Base'), array('controller' => 
> 'pages', 'action' => 'view','knowledge-base', 'admin' => false));
> echo $this->Html->link(__('Contact'), array('controller' => 'pages', 
> 'action' => 'support', 'admin' => false));
>
> My routes.php:
> Router::connect('/', array('controller' => 'pages', 'action' => 'display', 
> 'home', 'language'=>'eng'));
> *[...] custom rules [...]*
> Router::connect('/:language/:controller/:action/*',
>   array(),
>   array('language' => 'eng|ita'));
> Router::connect('/:language/:controller',
>   array('action' => 'index'),
>   array('language' => 'eng|ita'));        
> Router::connect('/:language',
>   array('controller' => 'welcome', 'action' => 'index'),
>   array('language' => 'eng|ita'));
>
> My language selector:
> echo 
> $this->Html->link($this->Html->image('icons/flags/small/united_kingdom.jpg', 
> array('alt'=>'English','width'=>'25','height'=>'16')), 
> array('language'=>'eng'), array('title'=>'English','escape' => false)); 
> echo $this->Html->link($this->Html->image('icons/flags/small/italy.jpg', 
> array('alt'=>'Italiano','width'=>'25','height'=>'16')), 
> array('language'=>'ita'), array('title'=>'Italiano','escape' => false)); 
>
>
> Now, when I'm visiting custom pages liike "contact" above it works great, 
> but when I'm in a page view like the "Knowledge base" one above the 
> language switcher fails because the Router doesn't consider the $page 
> variable! 
> So the generated url is: 
>    http://localhost/work/mysite/app/webroot/ita/pages/view
> while the one in the top menu is 
>    http://localhost/work/mysite/app/webroot/ita/pages/view/knowledge-base
>
> What's wrong?
> Thanks
>
>
> [1] 
> http://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html
> [2] 
> http://colorblindprogramming.com/multiple-languages-in-a-cakephp-2-application-in-5-steps(with
>  all the comments and modifications)
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to