From 8fc646cf0858f9fe12229fea63bfc2d587f5b88c Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Sat, 23 Jul 2011 19:03:54 +0000 Subject: [PATCH] DifferenceEngine: introduce setDiffLang() to change the language in which the diff text is written. Translate: set the the diff text according to the source language, on Special:PageTranslation and the translation messages. (Also fix direction of CSS class mw-translate-fuzzy). --- includes/diff/DifferenceEngine.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index aeb9b485d9..034f0da6e9 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -25,6 +25,7 @@ class DifferenceEngine { var $mOldid, $mNewid; var $mOldtitle, $mNewtitle, $mPagetitle; var $mOldtext, $mNewtext; + var $mDiffLang; /** * @var Title @@ -74,6 +75,9 @@ class DifferenceEngine { } wfDebug( "DifferenceEngine old '$old' new '$new' rcid '$rcid'\n" ); + # Default language in which the diff text is written. + $this->mDiffLang = $this->mTitle->getPageLanguage(); + if ( 'prev' === $new ) { # Show diff between revision $old and the previous one. # Get previous one from DB. @@ -938,10 +942,9 @@ CONTROL; * @return string */ function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) { - // shared.css sets diff in interface language/dir, - // but the actual content should be in the page language/dir - $pageLang = $this->mTitle->getPageLanguage(); - $tableClass = 'diff diff-contentalign-' . htmlspecialchars( $pageLang->alignStart() ); + // shared.css sets diff in interface language/dir, but the actual content + // is often in a different language, mostly the page content language/dir + $tableClass = 'diff diff-contentalign-' . htmlspecialchars( $this->mDiffLang->alignStart() ); $header = ""; if ( $diff ) { // Safari/Chrome show broken output if cols not used $header .= " @@ -981,6 +984,15 @@ CONTROL; $this->mRevisionsLoaded = true; } + /** + * Set the language in which the diff text is written + * (Defaults to page content language). + * @since 1.19 + */ + function setDiffLang( $lang ) { + $this->mDiffLang = wfGetLangObj( $lang ); + } + /** * Load revision metadata for the specified articles. If newid is 0, then compare * the old article in oldid to the current article; if oldid is 0, then -- 2.20.1