stranslateablebehavior Behavior that eases the translation of project model dynamic content.

  1. Intoduction
  2. Setup
  3. Usage
  4. Compatibility
  5. Links
  6. History

Intoduction ¶

//Somewhere in controller:
$model = Page::model()->findPk(1);
echo $model->text; // Outputs Привет!
Yii::app()->language = 'en';
echo $model->text; // Outputs Hello!

Setup ¶

  1. Download extension.
  2. Copy STranslateableBehavior folder to extensions directory.
  3. Copy TranslateCommand.php to commands directory.

Usage ¶

1: Edit models, that you want to be able to translate. Enable STranslateableBehavior:

public function behaviors()
{
return array(     'translate'=>'application.extensions.STranslateableBehavior.STranslateableBehavior' );
}

2: Add translate method and define attributes to translate:

public function translate()
{
    // List of model attributes to translate
    return array('content', 'url'); //Example
}

Save model!

3: Edit config/main.php and add list of supported languages to app params array:

...
'params'=>array(
    'languages'=>array('ru', 'en'),
),
...

4: Create migration from command line run:

./yiic translate

Check migration php code!
Apply migration!

./yiic migrate

After migration you should see in your tables columns suffixed with language name.

Compatibility ¶

Tested only on Yii v1.1.8r3324 with MySQL on PHP 5.3

Links ¶

Github page
Forum topic

PS. Testers needed!

History ¶

2011-29-07 - Initial release. Note - this is first release and this extension is a try to find a new way of model translation in Yii projects.

5 0
13 followers
528 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Database
Developed by: kmdm kmdm
Created on: Jul 29, 2011
Last updated: 14 years ago

Downloads

show all

Related Extensions