Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
14 | 14 | */ |
15 | 15 | |
16 | | -define( 'TRANSLATE_VERSION', '2010-05-15' ); |
| 16 | +define( 'TRANSLATE_VERSION', '2010-05-24' ); |
17 | 17 | |
18 | 18 | $wgExtensionCredits['specialpage'][] = array( |
19 | 19 | 'path' => __FILE__, |
Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -275,7 +275,7 @@ |
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Perform an action on a given group/key/code |
279 | | - * |
| 279 | + * |
280 | 280 | * @param $action String: import/conflict/ignore |
281 | 281 | * @param $group Object: group object |
282 | 282 | * @param $key String: message key |
— | — | @@ -305,7 +305,8 @@ |
306 | 306 | } elseif ( $action === 'fuzzy' && $code !== 'en' ) { |
307 | 307 | $message = self::makeTextFuzzy( $message ); |
308 | 308 | return self::doImport( $title, $message, $comment, $user, $editFlags ); |
309 | | - |
| 309 | + } elseif ( $action === 'fuzzy' && $code == 'en' ) { |
| 310 | + return self::doFuzzy( $title, $message, $comment, $user, $editFlags ); |
310 | 311 | } else { |
311 | 312 | throw new MWException( "Unhandled action $action" ); |
312 | 313 | } |
— | — | @@ -330,15 +331,24 @@ |
331 | 332 | } |
332 | 333 | |
333 | 334 | public static function doFuzzy( $title, $message, $comment, $user, $editFlags = 0 ) { |
| 335 | + global $wgUser; |
| 336 | + |
| 337 | + if ( !$wgUser->isAllowed( 'translate-manage' ) ) { |
| 338 | + return wfMsg( 'badaccess-group0' ); |
| 339 | + } |
| 340 | + |
334 | 341 | $dbw = wfGetDB( DB_MASTER ); |
335 | 342 | |
336 | | - $titleText = $title->getDBKey(); |
| 343 | + // Work on all subpages of base title. |
| 344 | + $titleText = $title->getBaseText(); |
337 | 345 | |
338 | | - $condArray = array( |
339 | | - 'page_namespace' => $title->getNamespace(), |
| 346 | + $namespace = $title->getNamespace(); |
| 347 | + $titleText = $dbw->escapeLike( $titleText ); |
| 348 | + $conds= array( |
| 349 | + 'page_namespace' => $namespace, |
340 | 350 | 'page_latest=rev_id', |
341 | 351 | 'rev_text_id=old_id', |
342 | | - "page_title LIKE '{$dbw->escapeLike( $titleText )}/%%'" |
| 352 | + 'page_title LIKE \'' . $titleText . '\/%\'' |
343 | 353 | ); |
344 | 354 | |
345 | 355 | $rows = $dbw->select( |
— | — | @@ -348,18 +358,26 @@ |
349 | 359 | __METHOD__ |
350 | 360 | ); |
351 | 361 | |
352 | | - $changed = array(); |
353 | | - |
| 362 | + // Edit with fuzzybot if there is no user. |
354 | 363 | if ( !$user ) { |
355 | 364 | $user = self::getFuzzyBot(); |
356 | 365 | } |
357 | 366 | |
| 367 | + // Process all rows. |
| 368 | + $changed = array(); |
358 | 369 | foreach ( $rows as $row ) { |
359 | 370 | $ttitle = Title::makeTitle( $row->page_namespace, $row->page_title ); |
360 | 371 | |
361 | | - $text = Revision::getRevisionText( $row ); |
362 | | - $text = self::makeTextFuzzy( $text ); |
| 372 | + // No fuzzy for English original |
| 373 | + if( $ttitle->getSubpageText() == 'en' ) { |
| 374 | + // Use imported text, not database text. |
| 375 | + $text = $message; |
| 376 | + } else { |
| 377 | + $text = Revision::getRevisionText( $row ); |
| 378 | + $text = self::makeTextFuzzy( $text ); |
| 379 | + } |
363 | 380 | |
| 381 | + // Do actual import |
364 | 382 | $changed[] = self::doImport( |
365 | 383 | $ttitle, |
366 | 384 | $text, |
— | — | @@ -367,32 +385,13 @@ |
368 | 386 | $user, |
369 | 387 | $editFlags |
370 | 388 | ); |
371 | | - |
372 | | - if ( $this->checkProcessTime() ) { |
373 | | - break; |
374 | | - } |
375 | 389 | } |
376 | 390 | |
377 | | - if ( count( $changed ) === count( $rows ) ) { |
378 | | - $comment = wfMsgForContentNoTrans( 'translate-manage-import-summary' ); |
379 | | - // FIXME: Leftover of refactoring from SpecialManageGroups::doFuzzy() |
380 | | - // Did not know what to do with this. Have to ask Nikerabbit. |
381 | | - // Probably have to add an extra parameter, but this part should |
382 | | - // have had a comment. |
383 | | - // $title = Title::makeTitleSafe( $title->getNamespace(), $title->getPrefixedDbKey() . '/en' ); |
384 | | - $changed[] = self::doImport( |
385 | | - $title, |
386 | | - $message, |
387 | | - $comment, |
388 | | - $user, |
389 | | - $editFlags |
390 | | - ); |
391 | | - } |
392 | | - |
| 391 | + // Format return text |
393 | 392 | $text = ''; |
394 | 393 | foreach ( $changed as $c ) { |
395 | 394 | $key = array_shift( $c ); |
396 | | - $text = "* " . wfMsgExt( $key, array(), $c ); |
| 395 | + $text .= "* " . wfMsgExt( $key, array(), $c ) . "\n"; |
397 | 396 | } |
398 | 397 | |
399 | 398 | return array( 'translate-manage-import-fuzzy', "\n" . $text ); |