[Extension] Translateable behavior

Hi all,

STranslateableBehavior is Yii behavior that eases the translation of project models. It automatically creates migrations and stores translated content in same table with language suffix.

See https://github.com/firstrow/STranslateableBehavior/wiki for more details.

Download here.

Testers needed!


Hello, i`m the first in answer you :).

I´m interesting in your project, and i am trying to use it in my test code but i am a newbie in yii and is difficult to use for me.

Could you give more detail of how use this extension?


Thanks. I’ll try to make a short video or detailed instructions tomorrow.

how can i get it to work with giix generated models?

Hello, little problem with extension:

Migration doesn’t work, but i already have fields like “title”, “title_en” in my database. As I realized for the implementation of behavior is sufficient for each field to create a duplicate with the suffix of the language.

I did everything as in instruction, but did not get the expected result.

$t = Page::model()->findByPk(1);

echo $t->text; // returns "123"

Yii::app()->language = 'en';

echo $t->text; // returns the same "123"

echo $t->text_en; // returns right value "456"

I’m trying to use this extension, I’ve defined the behaviours function and the translate one as described in the manual, but when I do ./yiic translate an exception is raised when a new instance of the founded ‘translatable’ class is created, i.e. at row 97 when this code is called $model = new $class_name;

this is the exception raised:

exception ‘CDbException’ with message ‘CDbConnection failed to open the DB connection: could not find driver’ in /var/www/aff/framework/db/CDbConnection.php:382

Stack trace:

#0 /var/www/aff/framework/db/CDbConnection.php(331): CDbConnection->open()

#1 /var/www/aff/framework/db/CDbConnection.php(309): CDbConnection->setActive(true)

#2 /var/www/aff/framework/base/CModule.php(388): CDbConnection->init()

#3 /var/www/aff/framework/base/CApplication.php(431): CModule->getComponent(‘db’)

#4 /var/www/aff/framework/db/ar/CActiveRecord.php(615): CApplication->getDb()

#5 /var/www/aff/framework/db/ar/CActiveRecord.php(2263): CActiveRecord->getDbConnection()

#6 /var/www/aff/framework/db/ar/CActiveRecord.php(379): CActiveRecordMetaData->__construct(Object(Accessory))

#7 /var/www/aff/framework/db/ar/CActiveRecord.php(394): CActiveRecord::model(‘Accessory’)

#8 /var/www/aff/framework/db/ar/CActiveRecord.php(78): CActiveRecord->getMetaData()

#9 /var/www/aff/application/protected/commands/TranslateCommand.php(97): CActiveRecord->__construct()

#10 /var/www/aff/application/protected/commands/TranslateCommand.php(35): TranslateCommand->_loadModelFile(’/var/www/aff/…’)

#11 /var/www/aff/framework/console/CConsoleCommandRunner.php(65): TranslateCommand->run(Array)

#12 /var/www/aff/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run(Array)

#13 /var/www/aff/framework/base/CApplication.php(162): CConsoleApplication->processRequest()

#14 /var/www/aff/framework/yiic.php(33): CApplication->run()

#15 /var/www/aff/application/protected/yiic.php(7): require_once(’/var/www/aff/…’)

#16 /var/www/aff/application/protected/yiic(4): require_once(’/var/www/aff/…’)

Normal application database connecting works.

Hi, have you defined DB connection in console.php?