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:
- 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
- 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
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
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' ) /* ... */
Displaying the editor
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 thoseYii::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