我正在使用 i18n 为我的网站进行翻译并翻译行为。
一旦用户单击更改语言按钮。所有文本和记录都将以中文显示。
但,
当用户点击其他页面时,只有通过 i18n 翻译的文本仍然显示为中文。数据库记录显示回原来的英文。
这是 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');
}
}
我想知道我哪里出错了?
有人可以帮忙吗?
谢谢