Yii Framework Forum: Ei18n Translation Module - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ei18n Translation Module Ei18 is a translation module to allow Yii’ers to easily manage missing Rate Topic: -----

#1 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 16 March 2012 - 07:20 PM

I have just released a translation module: Ei18n.

Description
Ei18 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.

-----

Please use this forum thread for bugs, feedback, improvements, etc...

Extension link on Yii repository: http://www.yiiframew...xtension/ei18n/

-----

Hope you find it as useful as it is for me...


Cheers
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
1

#2 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,166
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 March 2012 - 02:12 AM

Thanx Antonio for sharing. It looks very interesting.

I've just downloaded it and went to download the requirements, and found that Fancybox is "Now licensed under Creative Commons Attribution-NonCommercial 3.0" :-(

So I guess if I want to use it, I should change it by CJuiDialog. What do you think?
0

#3 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 17 March 2012 - 02:48 PM

View Posttellibus, on 17 March 2012 - 02:12 AM, said:

Thanx Antonio for sharing. It looks very interesting.

I've just downloaded it and went to download the requirements, and found that Fancybox is "Now licensed under Creative Commons Attribution-NonCommercial 3.0" :-(

So I guess if I want to use it, I should change it by CJuiDialog. What do you think?


I made use of Fancybox in order to make the module a bit nicer and thinking that as the task to manage translations are on development states (once all translations are done, is up to the backend to update them) the license wont affect it... but changing the module to CJuiDialog shouldn't be a hard task.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#4 User is offline   jowen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 191
  • Joined: 13-July 11
  • Location:Malaysia

Posted 09 April 2012 - 08:05 PM

hi guys,

i wonder the line
'onMissingTranslation' => array('Ei18n', 'missingTranslation'),
will cause my page become blanks, but it become ok when remove this line. Anyone know what cause this problem happens??

   
/* import the module */
   'import'=>array(
   /* ... */
       'application.modules.translate.TranslateModule',
 'components' => array(
        'messages' => array(
            'class' => 'CDbMessageSource',
            'onMissingTranslation' => array('Ei18n', 'missingTranslation'),    <---- this line
            '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'
        )



thanks guys.
0

#5 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 10 April 2012 - 05:40 AM

View Postjowen, on 09 April 2012 - 08:05 PM, said:

hi guys,

i wonder the line
'onMissingTranslation' => array('Ei18n', 'missingTranslation'),
will cause my page become blanks, but it become ok when remove this line. Anyone know what cause this problem happens??

   
/* import the module */
   'import'=>array(
   /* ... */
       'application.modules.translate.TranslateModule',
 'components' => array(
        'messages' => array(
            'class' => 'CDbMessageSource',
            'onMissingTranslation' => array('Ei18n', 'missingTranslation'),    <---- this line
            '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'
        )



thanks guys.



What that line says is that onMissingTranslation, the component should call Ei18n, have you preloaded the component? Check installation instructions.
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#6 User is offline   jowen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 191
  • Joined: 13-July 11
  • Location:Malaysia

Posted 10 April 2012 - 06:54 PM

hi Antonio Ramirez,

i follow the configuration Ei18n,unzip the file and copy the translate folder inside protected/modules. then
copy
Yii::app()->translate->renderMissingTranslationsEditor();
to column2 in layouts. The config main also follow to ei18n. The problem still happens!!

Pls helps. Thanks
0

#7 User is offline   vgeorgo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 26-December 12
  • Location:Brazil

Posted 04 April 2013 - 09:25 AM

Hi, its all working fine with the translations, the only problem I got is that when I make one ajax call rendering its return on a jQuery dialog, the translator doesn't recognize the new translations.

Is there a way to make it do that?
0

#8 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 258
  • Joined: 15-August 12

Posted 23 June 2014 - 01:00 AM

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax  error or access violation: 1064 You have an error in your SQL syntax;  check the manual that corresponds to your MySQL server version for the  right syntax to use near 'TYPE=InnoDB' at line 7. The SQL statement  executed was: 
				CREATE TABLE tbl_source_message
				(
					id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
					category VARCHAR(32) NOT NULL,
					message TEXT
 
				)TYPE=InnoDB   	


What is the problem?

I create those tables manually but now getting this error when go to http://localhost/ind...p?r=translate/:
      
[b]Error 404[/b]
  The system is unable to find the requested action "index".


Can anyone describes about usage of this extension?
0

#9 User is offline   Paul78 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-April 12

Posted 19 August 2014 - 12:26 PM

I made a little adjustment to the module to also be able to use this in AJAX requests. There are probably better ways to do this but it got the job done for me.

in WTranslate.php (under Widgets) replace the function registerScripts with :
public function registerScripts()
	{
		$translations = function_exists('json_encode') ? json_encode($this->translations) : CJSON::encode($this->translations);
		if(!Yii::app()->request->isAjaxRequest ) 
		{
		$js = <<<EOD
		var wtranslate = (function($){
			var open = false;
			var l = null;
			var t = {$translations};
			var pub = {
				msg: function(o){
					if(jbar) {jbar.open(o);}
				},
				add: function(col, obj){
					var li = $('<li/>').addClass('item');
					if (obj.new == 'yes')
						var div = $('<div/>').text(obj.text);
					else
						var div = $('<div/>').text(obj.text).addClass('edited');
						
					var a = $('<a/>',{class: 'wtranslate fancybox.ajax', id:'wt-'+obj.ref, href: obj.url}).text('edit');
					
					var span = $('<span/>').append(a);
					div.append(span);
					li.append(div);
				
					$('ul',col).append(li);
					col.show();
				},
				update: function (f) 
				{
					var data = f.serialize();
					$.ajax({
						url: f.attr('action'),
						data: data,
						dataType: 'json',
						type: 'post',
						success: function(d){
							if(typeof d == 'object')
							{
								var a = $('#wt-'+d.id);
								if(a.length){
									a.closest('div').addClass('edited');
								}
								jbar.open(d);
							}
						}
					});
					$.fancybox.close();
				},
				buildLinks: function() {
					var cnt = 1;
					for(i=0; i<t.length; i++)
					{
						
						this.add($('.col'+cnt, l), t[i]);
						if(++cnt > 3) {cnt = 1;}
					}
				},
				buildSlider: function(){
					l = $('<div/>').attr('id','wtranslator-footerSlideContainer');
					var button = $('<div/>').attr('id','wtranslator-footerSlideButton');
					var content = $('<div/>').attr('id','wtranslator-footerSlideContent');
					var text = $('<div/>').attr('id','wtranslator-footerSlideText');
					text.html("\
					<h3>{$this->title}</h3>\
					<div id='one-true'>\
						<div class='col col1'><ul></ul></div>\
						<div class='col col2'><ul></ul></div>\
						<div class='col col3'><ul></ul></div>\
					</div>");
					content.append(text);
					l.append(button,content);
					$('body').append(l);
				},
				init: function(){
					//if( !t.length ) return; /* no missing translations? what do you wish to do?*/
					this.buildSlider();
					this.buildLinks();
					$(".wtranslate").fancybox({
						width	: 800,
						height	: 600,
						minWidth	: 800,
						fitToView	: false,
						autoSize	: false,
						closeClick	: false,
						openEffect	: 'none',
						closeEffect	: 'none',
						topRatio    : 0,
						afterShow	: function(){
							$('.wtranslate-wysiwyg').wysiwyg({initialContent:''});
							$(".fancybox-wrap").css({"top":0, "margin":"100px 0 0"});
						}
					});
					jQuery('.fancybox-wrap').css('margin-top', '120px');
					$('#wtranslator-footerSlideButton').on('click',function(){
						var content = $('#wtranslator-footerSlideContent');
						var w = $('#wtranslator-footerSlideText').height() + 50;
						if(content.is(':animated'))
							return false;

						if(content.hasClass('footerSlideVisible')){
							content.animate({ height: '0px' }).removeClass('footerSlideVisible').addClass('footerSlideHidden');
							$(this).css('backgroundPosition', 'top left');
						}
						else {
							content.animate({ height: w+'px' }).removeClass('footerSlideHidden').addClass('footerSlideVisible');
							$(this).css('backgroundPosition', 'bottom left');
						}
						return false;
					});
					$(document).on('click', '.translate-buttons > a', function() {
						var action = $(this).attr('rel');
						if(action=='submit')
						{
							var frm = $('.translate-form > form');
							wtranslate.update(frm);
						}
						else if(action=='close')
						{
							$.fancybox.close();
						}
						return false;
					});
				}
			};
			
			return pub;
			
		})(jQuery);
EOD;
		$assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets');

		$cs = Yii::app()->clientScript;
		
		/* widget js files */
		$cs->registerCoreScript('jquery');
		$cs->registerScript(__CLASS__ . 'EndJS', $js, CClientScript::POS_END);

		/* fancybox files */
		$cs->registerCssFile($assets . '/fancybox/source/jquery.fancybox.css');
		$cs->registerScriptFile($assets . '/fancybox/source/jquery.fancybox.pack.js', CClientScript::POS_END);

		/* jwysiwyg files */
		$cs->registerCssFile($assets . '/jwysiwyg/jquery.wysiwyg.css');
		$cs->registerScriptFile($assets . '/jwysiwyg/jquery.wysiwyg.js', CClientScript::POS_END);
		$cs->registerScriptFile($assets . '/jwysiwyg/controls/wysiwyg.link.js', CClientScript::POS_END);
		$cs->registerScriptFile($assets . '/jwysiwyg/controls/wysiwyg.table.js', CClientScript::POS_END);

		/* modified jbar files */
		$cs->registerCssFile($assets . '/jbar/css/jbar.style.css');
		$cs->registerScriptFile($assets . '/jbar/jquery.bar.js', CClientScript::POS_END);


		/* widget style files */
		$cs->registerCssFile($assets . '/wtranslator.style.css');

		/* init the module on document ready */
		$cs->registerScript('WTranslateReadyJS', 'wtranslate.init();', CClientScript::POS_READY);
		
		}
		else
		{
			
		$js = <<<EOD
			var t = {$translations};
			var l = null;
			function add(col, obj){
				var li = $('<li/>').addClass('item');
				if (obj.new == 'yes')
					var div = $('<div/>').text(obj.text);
				else
					var div = $('<div/>').text(obj.text).addClass('edited');
					
				var a = $('<a/>',{class: 'wtranslate fancybox.ajax', id:'wt-'+obj.ref, href: obj.url}).text('edit');
				
				var span = $('<span/>').append(a);
				div.append(span);
				li.append(div);
				$('ul',col).append(li);
				col.show();
			}
			
			function buildLinks() {
				var cnt = 1;
				for(i=0; i<t.length; i++)
				{
					
					this.add($('.col'+cnt, l), t[i]);
					if(++cnt > 3) {cnt = 1;}
				}
			}
			
			buildLinks();
EOD;
		}
		$cs = Yii::app()->clientScript;
		$cs->registerScript(__CLASS__ . 'EndJS', $js, CClientScript::POS_END);
	}


And put this in every partial view rendered by Ajax:

echo Yii::app()->translate->renderMissingTranslationsEditor();


Hope this helps!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users