Yii 1.1: ei18n

Ei18n is a translation module to allow Yii'ers to easily manage missing translations on application pages


Ei18n is a translation module to allow Yii'ers to easily manage missing translations on application pages. It is heavily inspired by yii.translate developed by Gustavo Salomé Silva gusnips.

The reason I developed a new one is because Gustavo's approach wasn't suitable for my needs, I wanted the translation to be specific to the languages I was editing and not to edit them all at once. Also, the theme was not rendering right and I couldn't make it work properly as my design was not developed with the one Yii comes by default.

I wanted to make it as a component only but then I realized that to be a module was the right way to go as I could automate language edition without making the user tweak far too many things.

The following is a snapshot of the editor:

Ei18n Editor


  • Automatically creates the message translation tables on your database.
  • The module allows the edition of translations specified by categories. Its utility widget WTranslate handles that very smoothly.
  • All is AJAX based at the frontend. I thought that would be better to leave to developers the creation of a backend in order to edit translation on a regular basis.
  • Its Ei18 component has a couple of helper functions to also manage language setting automation. Check also its Set CAction class to be included on the controller that will handle language setting.


  • jQuery v1.7 or higher (tested with jQuery v1.7)
  • fancybox 2.0.5
  • jwysiwyg 0.97.2
  • jbar Jquery plugin -Modified version
  • Yii 1.9
  • Translations handled by CDbMessageSource

Tested With

  • Chrome 17.0.963.56 on Macosx Lion
  • Safari Version 5.1.3 (7534.53.10) on Macosx Lion
  • Firefox 8.0.1 Macosx Lion
  • Firefox 9.0.1 Macosx Lion

Quick Start

The configuration is a bit troublesome, but once you get it up and running editing your missing translations will be peanuts.

In order to make it run we need to:

  • Configure Ei18n on your main.php configuration file
  • Render the widget on your base layout file

Configuring Ei18n

On you main.php configuration file do the following:

/* import the module */
   /* ... */
   /* ... */
/* setup your default language */
    'language'=> 'en',
/* setup message translation method */
       'messages' => array(
           'class' => 'CDbMessageSource',
           'onMissingTranslation' => array('Ei18n', 'missingTranslation'),
           'sourceMessageTable' => 'tbl_source_message',
           'translatedMessageTable' => 'tbl_message'
/* setup global translate application component */
       'translate' => array(
           'class' => 'translate.components.Ei18n',
           'createTranslationTables' => true,
           'connectionID' => 'db',
           'languages' => array(
                    'en' => 'English',
                    'es' => 'Español',
                    'it' => 'Italiano'
/* setup the module */
       'modules' => array(
/* preload the global translate application component */
       'preload'=> array(
        /* ... */

Displaying the editor

Once the module and the translation component have been set. You just use any of the following helper functions:

    /* or only certain categories*/
/* Yii::app()->translate->renderTranslationsEditor(array('index','menu')); */

The first method and due to the view rendering nature of Yii, I highly recommend the display of those functions at the bottom of your main or base layout, as it will collect all missing ones throughout the rendering processes.

Remember the translations are automatically collected when Yii goes through all those Yii::t('category','translation text'); statements throughout your code and fires the onMissingTranslation event.

Yes, is on Github

Anybody willing to help improving E1i8n is highly welcome. Check the github repository on the resources section.


  • version 1.0.0 Initial version release


Total 8 comments

#15006 report it
gb5256 at 2013/09/27 04:37pm
tbl_message stays empty, EDIT

ok I am getting closer. I have just added by hand one record to the tbl_message table. Afterwards I was able to edit the translations with this module as expected.

Perhaps I do not understand this module correctly...

Do I have to add all messages from the source_table at least for "en" in a separete way?

hmmmmmmmm. any ideas?


#15005 report it
gb5256 at 2013/09/27 03:50pm
tbl_message stays empty

Hello out there. First of all, great Module. This will help me with my project quite a lot. But I do have a problem in the setup.

I have installed the latest version from Git. It has auto-generated the tables tbl_message and tbl_source_message. The source messages tables received content via the module, that works. But if I visit one of the pages where content to translate is, the ei18n does show the bar, but it does not show anything to translate. There are no errors. I have checked the log files: It does check the table for the current language. None of the SQLs does throw any errors, I ran them by hand to be sure. hmmm.

Any ideas? gb5256

#8217 report it
BlueFire at 2012/05/18 05:19pm

You have to change this string in the auto creation tables




#7972 report it
PinkBrainPlan at 2012/04/30 09:03am
Pls. update the component E18N on line 270 to

$language = is_string (Yii::app()->getRequest()->getPreferredLanguage())?Yii::app()->getRequest()->getPreferredLanguage():'en';

#7928 report it
Antonio Ramirez at 2012/04/26 03:23pm

Thanks for your feedback!

#7925 report it
briiC.lv at 2012/04/26 12:44pm
Installed very smoothly.. (and for PostgreSql)

Hi, thanks for this extension. Just giving feedback, that installation went smoothly (pre-created tables in postgreSql). And now enyoing :) I'm not sure about all these dependencies but all is working.. Only last tweaks: set it to load only on local (dump and restore later on live) or zip with access roles.

Thansk again and good luck! +1

#7408 report it
Antonio Ramirez at 2012/03/21 06:58am

All additions to the library welcome: Extension on Github

#7403 report it
Lastik at 2012/03/20 05:50pm
CDbMessageSource only?

what about work with CPhpMessageSource?

Leave a comment

Please to leave your comment.

Create extension