| Index: trunk/extensions/Translate/TranslateEditAddons.php |
| — | — | @@ -418,16 +418,26 @@ |
| 419 | 419 | list( $key, $code, $group ) = self::getKeyCodeGroup( $article->getTitle() ); |
| 420 | 420 | if ( !$group ) return true; |
| 421 | 421 | $def = $group->getMessage( $key, 'en' ); |
| 422 | | - $content = TranslateUtils::convertWhiteSpaceToHTML( $content ); |
| | 422 | + $content = self::preserveWhitespaces( $content ); |
| | 423 | + $def = self::preserveWhitespaces( $def ); |
| 423 | 424 | $deftext = wfMsgNoTrans( 'translate-edit-show-def' ); |
| 424 | 425 | $trans = wfMsgNoTrans( 'translate-edit-show-trans' ); |
| 425 | 426 | $content = <<<HTML |
| 426 | 427 | <table class=wikitable> |
| 427 | 428 | <tr><th>$deftext</th><th>$trans</th></tr> |
| 428 | | - <tr><td><nowiki>$def</nowiki></td><td><nowiki>$content</nowiki></td></tr> |
| | 429 | + <tr><td style=vertical-align:top>$def</td><td style=vertical-align:top>$content</td></tr> |
| 429 | 430 | </table> |
| 430 | 431 | HTML; |
| 431 | 432 | } |
| 432 | 433 | return true; |
| 433 | 434 | } |
| | 435 | + |
| | 436 | + public static function preserveWhitespaces( $text ) { |
| | 437 | + $text = wfEscapeWikiText( $text ); |
| | 438 | + $text = preg_replace( '/^ /m', ' ', $text ); |
| | 439 | + $text = preg_replace( '/ $/m', ' ', $text ); |
| | 440 | + $text = preg_replace( '/ /', '  ', $text ); |
| | 441 | + $text = str_replace( "\n", '<br />', $text ); |
| | 442 | + return $text; |
| | 443 | + } |
| 434 | 444 | } |