http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99379
Revision: 99379 Author: nikerabbit Date: 2011-10-09 22:09:53 +0000 (Sun, 09 Oct 2011) Log Message: ----------- Doing r81168 properly, essentially reverting it. Modified Paths: -------------- trunk/extensions/Translate/MessageCollection.php trunk/extensions/Translate/TranslateTasks.php trunk/extensions/Translate/utils/MessageTable.php Modified: trunk/extensions/Translate/MessageCollection.php =================================================================== --- trunk/extensions/Translate/MessageCollection.php 2011-10-09 21:16:04 UTC (rev 99378) +++ trunk/extensions/Translate/MessageCollection.php 2011-10-09 22:09:53 UTC (rev 99379) @@ -81,6 +81,11 @@ } + /// @return String + public function getLanguage() { + return $this->code; + } + // Data setters /** Modified: trunk/extensions/Translate/TranslateTasks.php =================================================================== --- trunk/extensions/Translate/TranslateTasks.php 2011-10-09 21:16:04 UTC (rev 99378) +++ trunk/extensions/Translate/TranslateTasks.php 2011-10-09 22:09:53 UTC (rev 99379) @@ -188,8 +188,7 @@ } protected function output() { - $code = $this->options->getLanguage(); - $table = new MessageTable( $this->collection, $this->group, $code ); + $table = new MessageTable( $this->collection, $this->group ); $table->appendEditLinkParams( 'loadtask', $this->getId() ); return $table->fullTable(); @@ -212,8 +211,7 @@ } protected function output() { - $code = $this->options->getLanguage(); - $table = new MessageTable( $this->collection, $this->group, $code ); + $table = new MessageTable( $this->collection, $this->group ); $table->appendEditLinkParams( 'loadtask', $this->getId() ); $table->setReviewMode(); Modified: trunk/extensions/Translate/utils/MessageTable.php =================================================================== --- trunk/extensions/Translate/utils/MessageTable.php 2011-10-09 21:16:04 UTC (rev 99378) +++ trunk/extensions/Translate/utils/MessageTable.php 2011-10-09 22:09:53 UTC (rev 99379) @@ -13,9 +13,8 @@ */ class MessageTable { protected $reviewMode = false; - protected $collection = null; - protected $group = null; - protected $code = null; + protected $collection; + protected $group; protected $editLinkParams = array(); protected $headers = array( @@ -24,22 +23,18 @@ 'default' => array( 'msg', 'allmessagesdefault' ), ); - public function __construct( MessageCollection $collection, MessageGroup $group, $code ) { + public function __construct( MessageCollection $collection, MessageGroup $group ) { $this->collection = $collection; $this->group = $group; - $this->code = $code; $this->setHeaderText( 'table', $group->getLabel() ); $this->appendEditLinkParams( 'loadgroup', $group->getId() ); } - /** - * @param $array array - */ public function setEditLinkParams( array $array ) { $this->editLinkParams = $array; } - public function appendEditLinkParams( $key, $value ) { + public function appendEditLinkParams( /*string*/ $key, /*string*/ $value ) { $this->editLinkParams[$key] = $value; } @@ -105,10 +100,6 @@ $optional = wfMsgHtml( 'translate-optional' ); - $mlang = Language::factory( $this->code ); - $mespa = array( 'dir' => $mlang->getDir(), 'lang' => $this->code ); - unset( $mlang ); - $batch = new LinkBatch(); if ( method_exists( $batch, 'setCaller' ) ) { $batch->setCaller( __METHOD__ ); @@ -122,6 +113,9 @@ $batch->execute(); + $sourceLang = Language::factory( $this->group->getSourceLanguage() ); + $targetLang = Language::factory( $this->collection->getLanguage() ); + $output = ''; $this->collection->initMessages(); // Just to be sure foreach ( $this->collection as $key => $m ) { @@ -129,13 +123,15 @@ $title = $this->keyToTitle( $key ); $original = $m->definition(); - # @todo Handle directionality of fallback language(s) - if ( $m->translation() ) { + + if ( $m->translation() !== null ) { $message = $m->translation(); - $rclasses = array_merge ( $mespa, array( 'class' => 'translated' ) ); + $rclasses = self::getLanguageAttributes( $targetLang ); + $rclasses['class'] = 'translated'; } else { $message = $original; - $rclasses = array( 'lang' => 'en', 'dir' => 'ltr', 'class' => 'untranslated' ); + $rclasses = self::getLanguageAttributes( $sourceLang ); + $rclasses['class'] = 'untranslated'; } global $wgLang; @@ -209,4 +205,16 @@ return Title::makeTitle( $namespace, $titleText ); } + + protected static function getLanguageAttributes( Language $language ) { + global $wgTranslateDocumentationLanguageCode; + $code = $language->getCode(); + $dir = $language->getDir(); + if ( $code === $wgTranslateDocumentationLanguageCode ) { + // Should be good enough for now + $code = 'en'; + } + + return array( 'lang' => $code, 'dir' => $dir ); + } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs