Yii 1.1: multilingualactiverecord


This extension is give up, please visit new extension: i18n-activerecord

url: http://www.yiiframework.com/extension/i18n-activerecord/

This extension simplifies the handling of multilingual content stored in the database.

It assumes that you use two tables for your content (one for the main content and a second one for the translations) with a one-to-many relationship between them.




  • Yii 1.1 or above


  • Extract the release file under protected/extensions


See the following code example:

class Product extends JMultilingualActiveRecord
    public function localizedAttributes()
        return array('name','content');
    public function languages()
        return array('zh_cn');
    public function primaryLang()
        return array('en_us');
    public function langClassName()
        return __CLASS__.'Mui';
    public function langForeignKey()
        return 'owner_id';

Change Log

Alpha 2

  • add filter by special attribute useage: News::model()->localized('zh_cn', 'title')->findAll(); it will only match title is not empty rows

Total 2 comments

#23 report it
Veseliq at 2010/10/10 03:58am

After wasting few days trying to write behavior to do all that, I tried your ML AR and it does exactly what I want. Thank you!

#922 report it
Zeljko at 2010/02/02 04:44pm
Great work!

Thanks! It saved me a lot of time.

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: jerry2801
  • Category: Database
  • Votes: +2 / -1
  • Downloaded: 1,238 times
  • Created on: Jan 26, 2010
  • Last updated: Oct 25, 2010