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:

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:
On you main.php configuration file do the following:
/* import the module */ 'import'=>array( /* ... */ 'application.modules.translate.TranslateModule' /* ... */ /* setup your default language */ 'language'=> 'en', /* setup message translation method */ 'components'=>array( '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( 'translate' ), /* preload the global translate application component */ 'preload'=> array( 'translate' ) /* ... */
Once the module and the translation component have been set. You just use any of the following helper functions:
Yii::app()->translate->renderMissingTranslationsEditor(); /* 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.
Anybody willing to help improving E1i8n is highly welcome. Check the github repository on the resources section.
Total 6 comments
You have to change this string in the auto creation tables
from:
To
$language = is_string (Yii::app()->getRequest()->getPreferredLanguage())?Yii::app()->getRequest()->getPreferredLanguage():'en';
Thanks for your feedback!
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
All additions to the library welcome: Extension on Github
what about work with CPhpMessageSource?
Leave a comment
Please login to leave your comment.