add language prefix to URL from cookie on page load in CakePHP

I'm quite new on cakePHP. I'm creating multilanguage page using this tutorial: i18n multilanguage tutorial everything is working fine, but on page load I need to add language prefix from cookie (localhost/eng instead of localhost/), this prefix appears when I select some menu, but I had a headache how to add prefix on pageload. Thanks for advices.

Upvotes: 1

Views: 240

Answers (1)

Choma
Choma

Reputation: 708

You can do a redirect in your AppController, after you call _setLanguage(). Something like:

$this->_setLanguage();
if( $this->here == '/' )
    $this->redirect(array('controller' => 'your_controller', 'action' => 'your_action', 'language' => $this->Session->read('Config.language')));

Upvotes: 1

Related Questions