Index: trunk/extensions/Translate/js/quickedit.js |
— | — | @@ -21,6 +21,28 @@ |
22 | 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
23 | 23 | */ |
24 | 24 | |
| 25 | +function MessageCheckUpdater( callback ) { |
| 26 | + this.callback = callback; |
| 27 | + |
| 28 | + this.act = function() { |
| 29 | + callback(); |
| 30 | + delete this.timeoutID; |
| 31 | + }, |
| 32 | + |
| 33 | + this.setup = function() { |
| 34 | + this.cancel(); |
| 35 | + var self = this; |
| 36 | + this.timeoutID = window.setTimeout( self.act, 600 ); |
| 37 | + }, |
| 38 | + |
| 39 | + this.cancel = function() { |
| 40 | + if(typeof this.timeoutID == "number") { |
| 41 | + window.clearTimeout(this.timeoutID); |
| 42 | + delete this.timeoutID; |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | + |
25 | 47 | var dialogwidth = false; |
26 | 48 | |
27 | 49 | function trlOpenJsEdit( page, group ) { |
— | — | @@ -61,7 +83,22 @@ |
62 | 84 | return false; |
63 | 85 | }); |
64 | 86 | |
65 | | - form.find( ".mw-translate-edit-area" ).focus(); |
| 87 | + var textarea = form.find( ".mw-translate-edit-area" ); |
| 88 | + textarea.focus(); |
| 89 | + var checks = form.find( ".mw-translate-messagechecks" ); |
| 90 | + if ( checks ) { |
| 91 | + |
| 92 | + var checker = new MessageCheckUpdater( function() { |
| 93 | + var url = wgScript + "?title=Special:Translate/editpage&suggestions=checks&page=$1&loadgroup=$2"; |
| 94 | + url = url.replace( "$1", page ).replace( "$2", group ); |
| 95 | + jQuery.post( url, { translation: textarea.val() } , function(mydata) { |
| 96 | + checks.html( mydata ); |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
| 100 | + textarea.keyup( function() { checker.setup(); } ); |
| 101 | + } |
| 102 | + |
66 | 103 | addAccessKeys( form ); |
67 | 104 | var b = form.find(".mw-translate-save"); b.val( b.val() + " (a)" ); |
68 | 105 | var b = form.find(".mw-translate-next"); b.val( b.val() + " (s)" ); |
Index: trunk/extensions/Translate/utils/TranslationEditPage.php |
— | — | @@ -74,6 +74,11 @@ |
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
| 78 | + if ( $this->suggestions === 'checks' ) { |
| 79 | + echo $helpers->getBoxes( $this->suggestions ); |
| 80 | + return; |
| 81 | + } |
| 82 | + |
78 | 83 | $translation = $helpers->getTranslation(); |
79 | 84 | $short = strpos( $translation, "\n" ) === false && strlen( $translation ) < 200; |
80 | 85 | $textareaParams = array( |
Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -193,6 +193,10 @@ |
194 | 194 | $all['translation-memory'] = array( $this, 'getLazySuggestionBox' ); |
195 | 195 | } elseif ( $suggestions === 'only' ) { |
196 | 196 | return (string) call_user_func( $all['translation-memory'], 'lazy' ); |
| 197 | + } elseif( $suggestions === 'checks' ) { |
| 198 | + global $wgRequest; |
| 199 | + $this->translation = $wgRequest->getText( 'translation' ); |
| 200 | + return (string) call_user_func( $all['check'] ); |
197 | 201 | } |
198 | 202 | |
199 | 203 | $boxes = array(); |
— | — | @@ -546,6 +550,8 @@ |
547 | 551 | protected function getCheckBox() { |
548 | 552 | global $wgTranslateDocumentationLanguageCode; |
549 | 553 | |
| 554 | + $placeholder = Html::element( 'div', array( 'class' => 'mw-translate-messagechecks' ) ); |
| 555 | + |
550 | 556 | if ( $this->group === null ) { |
551 | 557 | return; |
552 | 558 | } |
— | — | @@ -556,7 +562,7 @@ |
557 | 563 | $en = $this->getDefinition(); |
558 | 564 | |
559 | 565 | if ( strval( $translation ) === '' ) { |
560 | | - return null; |
| 566 | + return $placeholder; |
561 | 567 | } |
562 | 568 | |
563 | 569 | if ( $code === $wgTranslateDocumentationLanguageCode ) { |
— | — | @@ -574,7 +580,7 @@ |
575 | 581 | |
576 | 582 | $checks = $checker->checkMessage( $message, $code ); |
577 | 583 | if ( !count( $checks ) ) { |
578 | | - return null; |
| 584 | + return $placeholder; |
579 | 585 | } |
580 | 586 | |
581 | 587 | $checkMessages = array(); |
— | — | @@ -583,10 +589,11 @@ |
584 | 590 | $checkMessages[] = call_user_func_array( 'wfMsgExt', $checkParams ); |
585 | 591 | } |
586 | 592 | |
587 | | - return TranslateUtils::fieldset( |
| 593 | + return Html::rawElement( 'div', array( 'class' => 'mw-translate-messagechecks' ), |
| 594 | + TranslateUtils::fieldset( |
588 | 595 | wfMsgHtml( 'translate-edit-warnings' ), implode( '<hr />', $checkMessages ), |
589 | 596 | array( 'class' => 'mw-sp-translate-edit-warnings' ) |
590 | | - ); |
| 597 | + ) ); |
591 | 598 | } |
592 | 599 | |
593 | 600 | protected function getOtherLanguagesBox() { |