我已经按照手册中的说明使用 CakePHP 2.1 设置翻译行为,以及Stack 上的这个问题。我没有收到任何错误,但我翻译的帖子没有保存到我的 i18n 表中。
这是我的 PostModel.php:
class Post extends AppModel {
    public $title = 'Post';
    public $name = 'Post';
    public $body = 'Post';
    public $actAs = array(
        'Translate' => array(
            'title' => 'titleTranslation', 
            'body' => 'bodyTranslation'
        )
    );
    public $validate = array(
        'title' => array(
            'rule' => 'notEmpty'
        ),
        'body' => array(
            'rule' => 'notEmpty'
        )
    );
}
这是我在 PostsController.php 中的添加和编辑函数:
public function add() {
        if ($this->request->is('post')) {
            $this->Post->locale = 'fre';
            $this->Post->create();
        if ($this->Post->save($this->request->data)) {
            $this->Session->setFlash(__('Your post has been saved.', true));
            $this->redirect(array('action' => 'admin'));
        } else {
            $this->Session->setFlash(__('Unable to add your post.', true));
        }
    }
}
public function edit($id = null) {
    $this->Post->id = $id;
    if ($this->request->is('get')) 
    {
        $this->Post->locale = 'fre';
        $this->request->data = $this->Post->read();
    } 
    else 
    {
        if ($this->Post->save($this->request->data)) 
        {
            $this->Post->locale = 'fre';
            $this->Session->setFlash(__('Your post has been updated.', true));
            $this->redirect(array('action' => 'admin'));
        } 
        else 
        {
            $this->Session->setFlash(__('Unable to update your post.', true));
        }
    }
}
我使用控制台初始化了 i18n 表。我应该放下桌子并尝试重新初始化吗?不知道为什么会有问题。