currently I am studying cake php .
i am doing language translation tutorial.
so I want to load translation from database.
I am doing following steps
- created table
i18n
2)created entity
3)created table
<?php namespace App\Model\Table; use Cake\ORM\Table; use Cake\ORM\Behavior\Translate\TranslateTrait; class Category extends Table { public $useTable = 'Category'; public function initialize(array $config) { $this->addBehavior('Translate', ['fields' => ['name']]); } } ?>- printed translation value in controller
I18n::locale(‘es’);
$this->loadModel(‘Category’);
echo $this->Category->translation(‘es’)->name;
- but when executed this,following error comes.
Unknown method “translation”