Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | var $mOldid, $mNewid; |
27 | 27 | var $mOldtitle, $mNewtitle, $mPagetitle; |
28 | 28 | var $mOldtext, $mNewtext; |
| 29 | + var $mDiffLang; |
29 | 30 | |
30 | 31 | /** |
31 | 32 | * @var Title |
— | — | @@ -74,6 +75,9 @@ |
75 | 76 | } |
76 | 77 | wfDebug( "DifferenceEngine old '$old' new '$new' rcid '$rcid'\n" ); |
77 | 78 | |
| 79 | + # Default language in which the diff text is written. |
| 80 | + $this->mDiffLang = $this->mTitle->getPageLanguage(); |
| 81 | + |
78 | 82 | if ( 'prev' === $new ) { |
79 | 83 | # Show diff between revision $old and the previous one. |
80 | 84 | # Get previous one from DB. |
— | — | @@ -938,10 +942,9 @@ |
939 | 943 | * @return string |
940 | 944 | */ |
941 | 945 | function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) { |
942 | | - // shared.css sets diff in interface language/dir, |
943 | | - // but the actual content should be in the page language/dir |
944 | | - $pageLang = $this->mTitle->getPageLanguage(); |
945 | | - $tableClass = 'diff diff-contentalign-' . htmlspecialchars( $pageLang->alignStart() ); |
| 946 | + // shared.css sets diff in interface language/dir, but the actual content |
| 947 | + // is often in a different language, mostly the page content language/dir |
| 948 | + $tableClass = 'diff diff-contentalign-' . htmlspecialchars( $this->mDiffLang->alignStart() ); |
946 | 949 | $header = "<table class='$tableClass'>"; |
947 | 950 | if ( $diff ) { // Safari/Chrome show broken output if cols not used |
948 | 951 | $header .= " |
— | — | @@ -982,6 +985,15 @@ |
983 | 986 | } |
984 | 987 | |
985 | 988 | /** |
| 989 | + * Set the language in which the diff text is written |
| 990 | + * (Defaults to page content language). |
| 991 | + * @since 1.19 |
| 992 | + */ |
| 993 | + function setDiffLang( $lang ) { |
| 994 | + $this->mDiffLang = wfGetLangObj( $lang ); |
| 995 | + } |
| 996 | + |
| 997 | + /** |
986 | 998 | * Load revision metadata for the specified articles. If newid is 0, then compare |
987 | 999 | * the old article in oldid to the current article; if oldid is 0, then |
988 | 1000 | * compare the current article to the immediately previous one (ignoring the |
Index: trunk/extensions/Translate/Translate.css |
— | — | @@ -1,5 +1,6 @@ |
2 | 2 | .mw-translate-fuzzy { |
3 | 3 | background-color: #FDD; |
| 4 | + direction: ltr; |
4 | 5 | } |
5 | 6 | .mw-translate-definition-preview { |
6 | 7 | font-family: monospace; |
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php |
— | — | @@ -347,7 +347,7 @@ |
348 | 348 | |
349 | 349 | /** Displays the sections and changes for the user to review */ |
350 | 350 | public function showPage( TranslatablePage $page, Array $sections ) { |
351 | | - global $wgOut; |
| 351 | + global $wgOut, $wgContLang; |
352 | 352 | |
353 | 353 | $wgOut->setSubtitle( $this->user->getSkin()->link( $page->getTitle() ) ); |
354 | 354 | TranslateUtils::injectCSS(); |
— | — | @@ -380,6 +380,7 @@ |
381 | 381 | |
382 | 382 | if ( $s->type === 'changed' ) { |
383 | 383 | $diff = new DifferenceEngine; |
| 384 | + $diff->setDiffLang( $wgContLang ); |
384 | 385 | $diff->setText( $s->getOldText(), $s->getText() ); |
385 | 386 | $text = $diff->getDiff( wfMsgHtml( 'tpt-diff-old' ), wfMsgHtml( 'tpt-diff-new' ) ); |
386 | 387 | $diff->showDiffStyle(); |
— | — | @@ -391,7 +392,9 @@ |
392 | 393 | $text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() ); |
393 | 394 | } |
394 | 395 | |
395 | | - $wgOut->addHTML( MessageWebImporter::makeSectionElement( $name, $s->type, $text ) ); |
| 396 | + # For changed text, the language is set by $diff->setDiffLang() |
| 397 | + $lang = $s->type === 'changed' ? null : $wgContLang; |
| 398 | + $wgOut->addHTML( MessageWebImporter::makeSectionElement( $name, $s->type, $text, $lang ) ); |
396 | 399 | } |
397 | 400 | |
398 | 401 | $deletedSections = $page->getParse()->getDeletedSections(); |
— | — | @@ -401,7 +404,7 @@ |
402 | 405 | foreach ( $deletedSections as $s ) { |
403 | 406 | $name = wfMsgHtml( 'tpt-section-deleted', htmlspecialchars( $s->id ) ); |
404 | 407 | $text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() ); |
405 | | - $wgOut->addHTML( MessageWebImporter::makeSectionElement( $name, $s->type, $text ) ); |
| 408 | + $wgOut->addHTML( MessageWebImporter::makeSectionElement( $name, $s->type, $text, $wgContLang ) ); |
406 | 409 | } |
407 | 410 | } |
408 | 411 | |
— | — | @@ -415,6 +418,7 @@ |
416 | 419 | $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-template' ); |
417 | 420 | |
418 | 421 | $diff = new DifferenceEngine; |
| 422 | + $diff->setDiffLang( $wgContLang ); |
419 | 423 | $diff->setText( $oldTemplate, $newTemplate ); |
420 | 424 | $text = $diff->getDiff( wfMsgHtml( 'tpt-diff-old' ), wfMsgHtml( 'tpt-diff-new' ) ); |
421 | 425 | $diff->showDiffStyle(); |
Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -470,12 +470,17 @@ |
471 | 471 | * @param $legend \string Legend as raw html. |
472 | 472 | * @param $type \string Contents of type class. |
473 | 473 | * @param $content \string Contents as raw html. |
| 474 | + * @param $lang Language The language in which the text is written. |
474 | 475 | * @return \string Section element as html. |
475 | 476 | */ |
476 | | - public static function makeSectionElement( $legend, $type, $content ) { |
| 477 | + public static function makeSectionElement( $legend, $type, $content, $lang = null ) { |
477 | 478 | $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" ); |
478 | 479 | $legendParams = array( 'class' => 'mw-tpt-sp-legend' ); |
479 | 480 | $contentParams = array( 'class' => 'mw-tpt-sp-content' ); |
| 481 | + if( $lang ) { |
| 482 | + $contentParams['dir'] = wfGetLangObj( $lang )->getDir(); |
| 483 | + $contentParams['lang'] = wfGetLangObj( $lang )->getCode(); |
| 484 | + } |
480 | 485 | |
481 | 486 | $items = new TagContainer(); |
482 | 487 | $items[] = new HtmlTag( 'div', new RawHtml( $legend ), $legendParams ); |
Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -902,6 +902,7 @@ |
903 | 903 | } |
904 | 904 | |
905 | 905 | $diff = new DifferenceEngine; |
| 906 | + $diff->setDiffLang( $this->group->getSourceLanguage() ); |
906 | 907 | $diff->setText( $oldtext, $newtext ); |
907 | 908 | $diff->setReducedLineNumbers(); |
908 | 909 | $diff->showDiffStyle(); |
— | — | @@ -951,6 +952,7 @@ |
952 | 953 | } |
953 | 954 | |
954 | 955 | $diff = new DifferenceEngine; |
| 956 | + $diff->setDiffLang( $this->group->getSourceLanguage() ); |
955 | 957 | $diff->setText( $oldtext, $newtext ); |
956 | 958 | $diff->setReducedLineNumbers(); |
957 | 959 | $diff->showDiffStyle(); |