在CakePHP中加载页面时,在Cookie中添加语言前缀到URL中

问题描述:

我在cakePHP上很新。我使用本教程创建多语言页面:i18n multilanguage tutorial一切工作正常,但在页面加载时,我需要从cookie(localhost/eng而不是localhost /)添加语言前缀,当我选择某个菜单时出现此前缀,但我有头痛如何在页面加载前缀。感谢您的建议。在CakePHP中加载页面时,在Cookie中添加语言前缀到URL中

在调用_setLanguage()之后,您可以在AppController中执行重定向。例如:

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