我在爲我的網站使用i18n和翻譯行爲做翻譯。Cakephp 2.6國際化
一旦用戶點擊更改語言按鈕。所有的文本和記錄將以中文顯示。
但是,
當其他網頁的用戶點擊,只有文本,通過國際化翻譯在中國仍然顯示。數據庫記錄顯示爲英文原文。
這是在AppController中
function beforeFilter() {
$this->_setLanguage();
}
private function _setLanguage() {
//if the cookie was previously set, and Config.language has not been set
//write the Config.language with the value from the Cookie
if ($this->Cookie->read('lang') && !$this->Session->check('Config.language')) {
$this->Session->write('Config.language', $this->Cookie->read('lang'));
}
//if the session was previously set, and cookie language has not been set
//write the cookie language with the value from the session
else if (!$this->Cookie->read('lang') && $this->Session->check('Config.language')) {
$this->Cookie->write('lang', $this->Session->read('Config.language'));
}
//if the user clicked the language URL
if (isset($this->params['language'])) {
//then update the value in Session and the one in Cookie
$this->Session->write('Config.language', $this->params['language']);
$this->Cookie->write('lang', $this->params['language'], false, '20 days');
}
}
我不知道爲什麼我找到了問題所在的代碼?
任何人都可以幫忙嗎?
感謝
請始終指定要使用的確切CakePHP的版本!還請顯示如何/在哪裏設置實際的'Config.language' [**配置**](http://book.cakephp.org/2.0/en/development/configuration.html#configure-class)值(不是會話值)! – ndm