1
对不起,我希望你能理解我。 简化的代码看起来是这样的:CakePHP 3不支持默认语言
//在bootstrap.php中
的ini_set( 'intl.default_locale', '申');
// MainMenusTable.php
公共函数初始化(数组$配置) { 父::初始化($配置); ...
$this->addBehavior('Translate', ['fields' => ['title']]);
... }
//在控制器 - 这个作品!
public function add() { I18n::locale('eng'); $mainMenu = $this->MainMenus->newEntity(); if ($this->request->is('post')) { $mainMenu = $this->MainMenus->patchEntity($mainMenu, $this->request->data); $this->MainMenus->save($mainMenu) } $this->set(compact('mainMenu')); }
//在控制器,但本开不工作:
public function add() { I18n::locale('deu'); $mainMenu = $this->MainMenus->newEntity(); if ($this->request->is('post')) { $mainMenu = $this->MainMenus->patchEntity($mainMenu, $this->request->data); $this->MainMenus->save($mainMenu) } $this->set(compact('mainMenu')); }
我有同样的问题,当我读到记录
//在控制器 - 这工作!
I18n::locale('eng'); $query = $this->MainMenus->find('all')->order(['MainMenus.id' => 'ASC'])->all();
//在控制器,但本开不工作:
I18n::locale('deu'); $query = $this->MainMenus->find('all')->order(['MainMenus.id' => 'ASC'])->all();
对于 '申' 我手动输入记录。 你知道问题是什么吗? 谢谢!