Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php |
— | — | @@ -70,6 +70,7 @@ |
71 | 71 | $wgOut->addWikiMsg( 'tpt-nosuchpage', $title->getPrefixedText() ); |
72 | 72 | return; |
73 | 73 | } |
| 74 | + $wgOut->addModules( 'ext.translate.special.pagetranslation' ); |
74 | 75 | |
75 | 76 | if ( $action === 'discourage' || $action === 'encourage' ) { |
76 | 77 | $id = TranslatablePage::getMessageGroupIdFromTitle( $title ); |
— | — | @@ -528,6 +529,22 @@ |
529 | 530 | } |
530 | 531 | } |
531 | 532 | |
| 533 | + $priorityLangs = TranslateMetadata::get( $page->getMessageGroupId(), 'prioritylangs' ); |
| 534 | + $priorityForce = TranslateMetadata::get( $page->getMessageGroupId(), 'priorityforce' ); |
| 535 | + $priorityReason = TranslateMetadata::get( $page->getMessageGroupId(), 'priorityreason' ); |
| 536 | + $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-prioritylangs' ); |
| 537 | + $langSelector = Xml::languageSelector( $wgContLang-> getCode() ); |
| 538 | + $priorityLangsInput = Html::element( 'input', array( 'id' => 'tpt-prioritylangs', 'size' => '50', 'name' => 'prioritylangs', 'value' => $priorityLangs , ) ); |
| 539 | + if ( $priorityForce === 'on' ) { |
| 540 | + $forceLimit = Html::element( 'input', array( 'id' => 'tpt-priority-forcelimit', 'type' => 'checkbox', 'name' => 'forcelimit', 'checked' => 'checked' ) ); |
| 541 | + } else { |
| 542 | + $forceLimit = Html::element( 'input', array( 'id' => 'tpt-priority-forcelimit', 'type' => 'checkbox', 'name' => 'forcelimit' ) ); |
| 543 | + } |
| 544 | + $priorityReasonTextArea = Html::element( 'textarea', array( 'id' => 'tpt-priority-reason', 'name' => 'priorityreason' ), $priorityReason ); |
| 545 | + $forceLimitLabel = Html::element( 'label', array( 'id' => 'tpt-priority-forcelimit-label', 'for' => 'tpt-priority-forcelimit' ), wfMsgHtml( 'tpt-select-prioritylangs-force' ) ); |
| 546 | + $wgOut->addHTML( wfMsgHtml( 'tpt-select-prioritylangs' ) . $langSelector[1] . $priorityLangsInput ); |
| 547 | + $wgOut->addHTML( '<br/>' . $forceLimit . $forceLimitLabel . '<br/>' . wfMsgHtml( 'tpt-select-prioritylangs-reason' ) . $priorityReasonTextArea . '<br/>' ); |
| 548 | + |
532 | 549 | $wgOut->addHTML( |
533 | 550 | Xml::submitButton( wfMsg( 'tpt-submit' ) ) . |
534 | 551 | Xml::closeElement( 'form' ) |
— | — | @@ -619,6 +636,11 @@ |
620 | 637 | $page->addMarkedTag( $newrevision, $changed ); |
621 | 638 | $this->addFuzzyTags( $page, $changed ); |
622 | 639 | |
| 640 | + // Save the priority languages if any |
| 641 | + $priorityLangs = trim( $wgRequest->getVal( 'prioritylangs' ) ); |
| 642 | + $priorityForce = $wgRequest->getVal( 'forcelimit' ); |
| 643 | + $priorityReason = $wgRequest->getVal( 'priorityreason' ); |
| 644 | + |
623 | 645 | global $wgUser; |
624 | 646 | $logger = new LogPage( 'pagetranslation' ); |
625 | 647 | $params = array( |
— | — | @@ -627,6 +649,24 @@ |
628 | 650 | 'changed' => count( $changed ), |
629 | 651 | ); |
630 | 652 | $logger->addEntry( 'mark', $page->getTitle(), null, array( serialize( $params ) ) ); |
| 653 | + if ( $priorityLangs ) { |
| 654 | + $groupId = $page->getMessageGroupId(); |
| 655 | + TranslateMetadata::set( $groupId, 'prioritylangs', trim( $priorityLangs, ',' ) ); |
| 656 | + if ( $priorityForce ) { |
| 657 | + TranslateMetadata::set( $groupId, 'priorityforce', $priorityForce ); |
| 658 | + } else { |
| 659 | + TranslateMetadata::set( $groupId, 'priorityforce', 'off' ); |
| 660 | + } |
| 661 | + if ( trim( $priorityReason ) ) { |
| 662 | + TranslateMetadata::set( $groupId, 'priorityreason', $priorityReason ); |
| 663 | + } |
| 664 | + $params = array( |
| 665 | + 'user' => $wgUser->getName(), |
| 666 | + 'languages' => $priorityLangs, |
| 667 | + 'force' => $priorityForce, |
| 668 | + ); |
| 669 | + $logger->addEntry( 'prioritylanguages', $page->getTitle(), null, array( serialize( $params ) ) ); |
| 670 | + } |
631 | 671 | |
632 | 672 | $page->getTitle()->invalidateCache(); |
633 | 673 | $this->setupRenderJobs( $page ); |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -247,7 +247,11 @@ |
248 | 248 | ) + $resourcePaths; |
249 | 249 | |
250 | 250 | $wgResourceModules['ext.translate.special.pagetranslation'] = array( |
| 251 | + 'scripts' => 'resources/ext.translate.special.pagetranslation.js', |
251 | 252 | 'styles' => 'resources/ext.translate.special.pagetranslation.css', |
| 253 | + 'dependencies' => array( |
| 254 | + 'jquery.ui.autocomplete', |
| 255 | + ), |
252 | 256 | 'position' => 'top', |
253 | 257 | ) + $resourcePaths; |
254 | 258 | |
Index: trunk/extensions/Translate/PageTranslation.i18n.php |
— | — | @@ -64,7 +64,11 @@ |
65 | 65 | 'tpt-other-pages' => '{{PLURAL:$1|An old version of this page is|Older versions of these pages are}} marked for translation, |
66 | 66 | but the latest {{PLURAL:$1|version|versions}} cannot be marked for translation.', |
67 | 67 | 'tpt-discouraged-pages' => '{{PLURAL:$1|This page has|These pages have}} been discouraged from further translation.', |
68 | | - |
| 68 | + 'tpt-select-prioritylangs' => 'Preferred languages(comma seperated language codes): ', |
| 69 | + 'tpt-select-prioritylangs-force' => 'Limit translation to these languages alone', |
| 70 | + 'tpt-select-prioritylangs-reason' => 'Reason for setting this set of preferred languages(optional): ', |
| 71 | + 'tpt-sections-prioritylangs' => 'Preferred Languages', |
| 72 | + |
69 | 73 | 'tpt-rev-mark' => 'mark for translation', |
70 | 74 | 'tpt-rev-unmark' => 'remove from translation', |
71 | 75 | 'tpt-rev-discourage' => 'discourage', |
— | — | @@ -249,6 +253,10 @@ |
250 | 254 | 'tpt-translation-restricted' => 'Error message shown to user when translation to a language which is restricted by translation admin.', |
251 | 255 | 'tpt-discouraged-language-force' => 'Warning shown along with group description if the language is prevented from translation for the selected language', |
252 | 256 | 'tpt-discouraged-language' => 'Warning shown along with group description if the language is discouraged from translation for the selected language', |
| 257 | + 'tpt-select-prioritylangs' => 'Label for the input box to enter preferred languages', |
| 258 | + 'tpt-select-prioritylangs-force' => 'Label for the checkbox to make the translation restriction', |
| 259 | + 'tpt-select-prioritylangs-reason' => 'Label for the textbox to enter reason for restriction', |
| 260 | + 'tpt-sections-prioritylangs' => 'Section title in [[Special:PageTranslation]]', |
253 | 261 | 'pt-parse-open' => '"Translation template" is the structure of a translation page, where the place for the translations of each section is marked with a placeholder.', |
254 | 262 | 'pt-shake-multiple' => 'Each translation (=section) unit can only contain one marker.', |
255 | 263 | 'pt-shake-empty' => 'Translation unit (=section) is empty except for the translation marker (=<nowiki><!--T:1--></nowiki>)', |
Index: trunk/extensions/Translate/resources/ext.translate.special.pagetranslation.js |
— | — | @@ -0,0 +1,77 @@ |
| 2 | +/* |
| 3 | + * @author Santhosh Thottingal |
| 4 | + * jquery autocomplete based multiple selector for input box. |
| 5 | + * Autocompleted values will be available in input filed as comma seperated values. |
| 6 | + * The values for autocompletion is from the language selector in this case. |
| 7 | + * The input field is a php created one. |
| 8 | + * Credits: http://jqueryui.com/demos/autocomplete/#multiple |
| 9 | + */ |
| 10 | +jQuery( function( $ ) { |
| 11 | + $.widget( "ui.combobox", { |
| 12 | + _create: function() { |
| 13 | + var self = this, |
| 14 | + select = this.element.hide(), |
| 15 | + selected = select.children( ":selected" ); |
| 16 | + function split( val ) { |
| 17 | + return val.split( /,\s*/ ); |
| 18 | + } |
| 19 | + var input = this.input = $( '#tpt-prioritylangs' ) |
| 20 | + .autocomplete( { |
| 21 | + delay: 0, |
| 22 | + minLength: 0, |
| 23 | + source: function( request, response ) { |
| 24 | + var term = split( request.term ).pop(); |
| 25 | + var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" ); |
| 26 | + response( select.children( "option" ).map(function() { |
| 27 | + var text = $( this ).text(); |
| 28 | + var value = $( this ).val(); |
| 29 | + var term = split( request.term ).pop(); |
| 30 | + if ( this.value && ( !request.term || matcher.test(text) ) ) |
| 31 | + return { |
| 32 | + label: text.replace( |
| 33 | + new RegExp( |
| 34 | + "(?![^&;]+;)(?!<[^<>]*)(" + |
| 35 | + $.ui.autocomplete.escapeRegex(term) + |
| 36 | + ")(?![^<>]*>)(?![^&;]+;)", "gi" |
| 37 | + ), "<strong>$1</strong>" ), |
| 38 | + value: value, |
| 39 | + option: this |
| 40 | + }; |
| 41 | + }) ); |
| 42 | + }, |
| 43 | + select: function( event, ui ) { |
| 44 | + ui.item.option.selected = true; |
| 45 | + self._trigger( "selected", event, { |
| 46 | + item: ui.item.option |
| 47 | + }); |
| 48 | + var terms = split( $(this).val() ); |
| 49 | + // remove the current input |
| 50 | + terms.pop(); |
| 51 | + // add the selected item |
| 52 | + terms.push( ui.item.value ); |
| 53 | + // add placeholder to get the comma-and-space at the end |
| 54 | + terms.push( "" ); |
| 55 | + $( this ).val( terms.join( ", " ) ); |
| 56 | + return false; |
| 57 | + } |
| 58 | + |
| 59 | + }); |
| 60 | + |
| 61 | + input.data( "autocomplete" )._renderItem = function( ul, item ) { |
| 62 | + return $( "<li></li>" ) |
| 63 | + .data( "item.autocomplete", item ) |
| 64 | + .append( "<a>" + item.label + "</a>" ) |
| 65 | + .appendTo( ul ); |
| 66 | + }; |
| 67 | + |
| 68 | + }, |
| 69 | + |
| 70 | + destroy: function() { |
| 71 | + this.input.remove(); |
| 72 | + this.element.show(); |
| 73 | + $.Widget.prototype.destroy.call( this ); |
| 74 | + } |
| 75 | + }); |
| 76 | + |
| 77 | + $( "#wpUserLanguage" ).combobox(); |
| 78 | +} ); |
Property changes on: trunk/extensions/Translate/resources/ext.translate.special.pagetranslation.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 79 | + native |
Index: trunk/extensions/Translate/resources/ext.translate.special.pagetranslation.css |
— | — | @@ -16,3 +16,12 @@ |
17 | 17 | padding-left: 2em; |
18 | 18 | padding-right: 2em; |
19 | 19 | } |
| 20 | + |
| 21 | +.ui-autocomplete { |
| 22 | + max-height: 100px; |
| 23 | + overflow-y: auto; |
| 24 | + /* prevent horizontal scrollbar */ |
| 25 | + overflow-x: hidden; |
| 26 | + /* add padding to account for vertical scrollbar */ |
| 27 | + padding-right: 20px; |
| 28 | +} |