Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -340,7 +340,15 @@ |
341 | 341 | */ |
342 | 342 | $wgTranslateSupportUrl = false; |
343 | 343 | |
| 344 | +/** |
| 345 | + * When unprivileged users opens a translation editor, he will |
| 346 | + * see message stating that speical permission is needed for translating |
| 347 | + * messages. If this variable is defined, there is a button which will |
| 348 | + * take the user to that page to ask for permission. |
| 349 | + */ |
| 350 | +$wgTranslatePermissionUrl = 'Project:Translator'; |
344 | 351 | |
| 352 | + |
345 | 353 | # === Page translation feature === |
346 | 354 | |
347 | 355 | /** |
Index: trunk/extensions/Translate/README |
— | — | @@ -30,6 +30,7 @@ |
31 | 31 | |
32 | 32 | == Change log == |
33 | 33 | * 2011-10-28 |
| 34 | +- New configuration variable $wgTranslatePermissionUrl |
34 | 35 | - Message review feature, available to users in translate-proofr group |
35 | 36 | - Message collections can now have properties and allow filtering on them |
36 | 37 | This is still work in progress and is likely to get improvements over time |
Index: trunk/extensions/Translate/utils/TranslationEditPage.php |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | * disabled all other output. |
62 | 62 | */ |
63 | 63 | public function execute() { |
64 | | - global $wgOut, $wgServer, $wgScriptPath; |
| 64 | + global $wgOut, $wgServer, $wgScriptPath, $wgUser; |
65 | 65 | |
66 | 66 | $wgOut->disable(); |
67 | 67 | |
— | — | @@ -91,6 +91,11 @@ |
92 | 92 | 'lang' => $targetLang->getCode(), |
93 | 93 | 'dir' => $targetLang->getDir(), |
94 | 94 | ); |
| 95 | + |
| 96 | + if ( !$wgUser->isAllowed( 'translate' ) ) { |
| 97 | + $textareaParams['readonly'] = 'readonly'; |
| 98 | + } |
| 99 | + |
95 | 100 | $textarea = Html::element( 'textarea', $textareaParams, $translation ); |
96 | 101 | |
97 | 102 | $hidden = array(); |
— | — | @@ -125,6 +130,14 @@ |
126 | 131 | |
127 | 132 | $support = $this->getSupportButton( $this->getTitle() ); |
128 | 133 | |
| 134 | + if ( $wgUser->isAllowed( 'translate' ) ) { |
| 135 | + $bottom = "$summary$save$saveAndNext$skip$history$support"; |
| 136 | + } else { |
| 137 | + $text = wfMessage( 'translate-edit-nopermission' )->escaped(); |
| 138 | + $button = $this->getPermissionPageButton(); |
| 139 | + $bottom = "$text $button$skip$history$support"; |
| 140 | + } |
| 141 | + |
129 | 142 | // Use the api to submit edits |
130 | 143 | $formParams = array( |
131 | 144 | 'action' => "{$wgServer}{$wgScriptPath}/api.php", |
— | — | @@ -134,7 +147,7 @@ |
135 | 148 | $form = Html::rawElement( 'form', $formParams, |
136 | 149 | implode( "\n", $hidden ) . "\n" . |
137 | 150 | $helpers->getBoxes( $this->suggestions ) . "\n" . |
138 | | - "$textarea\n$summary$save$saveAndNext$skip$history$support" |
| 151 | + "$textarea\n$bottom" |
139 | 152 | ); |
140 | 153 | |
141 | 154 | echo Html::rawElement( 'div', array( 'class' => 'mw-ajax-dialog' ), $form ); |
— | — | @@ -211,4 +224,23 @@ |
212 | 225 | return $support; |
213 | 226 | } |
214 | 227 | |
| 228 | + protected function getPermissionPageButton() { |
| 229 | + global $wgTranslatePermissionUrl; |
| 230 | + if ( !$wgTranslatePermissionUrl ) return ''; |
| 231 | + |
| 232 | + $title = Title::newFromText( $wgTranslatePermissionUrl ); |
| 233 | + if ( !$title ) return ''; |
| 234 | + |
| 235 | + $button = Html::element( |
| 236 | + 'input', |
| 237 | + array( |
| 238 | + 'class' => 'mw-translate-askpermission', |
| 239 | + 'type' => 'button', |
| 240 | + 'value' => wfMsg( 'translate-edit-askpermission' ), |
| 241 | + 'data-load-url' => $title->getLocalUrl(), |
| 242 | + ) |
| 243 | + ); |
| 244 | + return $button; |
| 245 | + } |
| 246 | + |
215 | 247 | } |
Index: trunk/extensions/Translate/Translate.i18n.php |
— | — | @@ -6660,6 +6660,8 @@ |
6661 | 6661 | 'translate-edit-tmmatch' => 'Vastaavuus $1%', |
6662 | 6662 | 'translate-use-suggestion' => 'Korvaa nykyinen käännös tällä ehdotuksella.', |
6663 | 6663 | 'translate-edit-tab-list' => 'Viestiluettelo', |
| 6664 | + 'translate-edit-nopermission' => 'You need permission to translate messages.', |
| 6665 | + 'translate-edit-askpermission' => 'Request permission', |
6664 | 6666 | 'translate-magic-pagename' => 'Laajennettu MediaWikin kääntäminen', |
6665 | 6667 | 'translate-magic-help' => 'Voit kääntää toimintosivujen vaihtoehtoisia nimiä, taikasanoja ja nimiavaruuksien nimiä. |
6666 | 6668 | |
Index: trunk/extensions/Translate/resources/ext.translate.quickedit.js |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | return false; |
106 | 106 | } ); |
107 | 107 | |
108 | | - form.find( '.mw-translate-support' ).click( function() { |
| 108 | + form.find( '.mw-translate-support,.mw-translate-askpermission' ).click( function() { |
109 | 109 | // Can use .data() only with 1.4.3 or newer |
110 | 110 | window.open( $(this).attr('data-load-url') ); |
111 | 111 | return false; |