r94103 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94102‎ | r94103 | r94104 >
Date:12:16, 9 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
mw 1.16 and ms translate fixes
Modified paths:
  • /trunk/extensions/LiveTranslate/LiveTranslate.php (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/ext.lt.ms.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiveTranslate/LiveTranslate.php
@@ -103,7 +103,7 @@
104104 'includes/jquery.replaceText.js',
105105 'includes/jquery.liveTranslate.js'
106106 ),
107 - 'dependencies' => array( 'jquery', 'jquery.ui.button' ),
 107+ 'dependencies' => array( 'jquery'/*, 'jquery.ui.button'*/ ),
108108 'messages' => $egLTJSMessages
109109 );
110110
Index: trunk/extensions/LiveTranslate/includes/ext.lt.ms.js
@@ -16,6 +16,9 @@
1717 this.checkingForIdle = false;
1818 this.lastCompletion;
1919
 20+ // This is to enable a hack to decode quotes.
 21+ this.textAreaElement = document.createElement( 'textarea' );
 22+
2023 /**
2124 * Determines a chunk to translate of an DOM elements contents and calls the Microsoft Translate API.
2225 * Then calls itself if there is any remaining work to be done.
@@ -96,8 +99,8 @@
97100
98101 if ( untranslatedsentences.length == 0 ) {
99102 // If the current chunk was smaller then the max size, node translation is complete, so update text.
100 - window.textAreaElement.innerHTML = chunks.join( '' ); // This is a hack to decode quotes.
101 - element.replaceData( 0, element.length, window.textAreaElement.value );
 103+ self.textAreaElement.innerHTML = chunks.join( '' ); // This is a hack to decode quotes.
 104+ element.replaceData( 0, element.length, self.textAreaElement.value );
102105
103106 lt.debug( 'MS: Translated element' );
104107 self.handleTranslationCompletion();
@@ -187,7 +190,7 @@
188191 this.done();
189192 }
190193
191 - this.checkForIdleness = function( targetLang, hits ) {
 194+ this.checkForIdleness = function( hits ) {
192195 lt.debug( 'MS: checkForIdleness' );
193196 lt.debug( 'MS: last + 250: ' + ( this.lastCompletion + 250 ) );
194197 lt.debug( 'MS: now: ' + (new Date()).getTime() );
@@ -200,10 +203,10 @@
201204 }
202205
203206 if ( hits > 4 ) {
204 - this.invokeDone( targetLang );
 207+ this.invokeDone();
205208 }
206209 else if ( this.runningJobs > 0 ) {
207 - setTimeout( function() { self.checkForIdleness( targetLang, hits ); }, 250 );
 210+ setTimeout( function() { self.checkForIdleness( hits ); }, 250 );
208211 }
209212 }
210213
@@ -215,7 +218,7 @@
216219 this.handleTranslationCompletion = function() {
217220 if ( !this.checkingForIdle && this.runningJobs > 1 && this.runningJobs < 20 ) {
218221 this.checkingForIdle = true;
219 - setTimeout( function() { self.checkForIdleness( targetLang, 0 ); }, 250 );
 222+ setTimeout( function() { self.checkForIdleness( 0 ); }, 250 );
220223 }
221224
222225 if ( this.checkingForIdle ) {
Index: trunk/extensions/LiveTranslate/includes/LiveTranslate_Functions.php
@@ -60,14 +60,12 @@
6161
6262 $wgOut->addHeadItem(
6363 'ext.livetranslate',
64 - Html::linkedScript( $egLiveTranslateScriptPath . '/includes/ext.livetranslate.js' )
 64+ Html::linkedScript( $egLiveTranslateScriptPath . '/includes/ext.livetranslate.js' ) .
 65+ Html::linkedScript( $egLiveTranslateScriptPath . '/includes/ext.lt.tm.js' ) .
 66+ Html::linkedScript( $egLiveTranslateScriptPath . '/includes/jquery.replaceText.js' ) .
 67+ Html::linkedScript( $egLiveTranslateScriptPath . '/includes/jquery.liveTranslate.js' )
6568 );
6669
67 - $wgOut->addHeadItem(
68 - 'ext.livetranslate.tm',
69 - Html::linkedScript( $egLiveTranslateScriptPath . '/includes/ext.lt.tm.js' )
70 - );
71 -
7270 switch( $GLOBALS['egLiveTranslateService'] ) {
7371 case LTS_GOOGLE:
7472 $wgOut->addHeadItem(

Status & tagging log