r99379 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99378‎ | r99379 | r99380 >
Date:22:09, 9 October 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Doing r81168 properly, essentially reverting it.
Modified paths:
  • /trunk/extensions/Translate/MessageCollection.php (modified) (history)
  • /trunk/extensions/Translate/TranslateTasks.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageTable.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageCollection.php
@@ -81,6 +81,11 @@
8282
8383 }
8484
 85+ /// @return String
 86+ public function getLanguage() {
 87+ return $this->code;
 88+ }
 89+
8590 // Data setters
8691
8792 /**
Index: trunk/extensions/Translate/TranslateTasks.php
@@ -188,8 +188,7 @@
189189 }
190190
191191 protected function output() {
192 - $code = $this->options->getLanguage();
193 - $table = new MessageTable( $this->collection, $this->group, $code );
 192+ $table = new MessageTable( $this->collection, $this->group );
194193 $table->appendEditLinkParams( 'loadtask', $this->getId() );
195194
196195 return $table->fullTable();
@@ -212,8 +211,7 @@
213212 }
214213
215214 protected function output() {
216 - $code = $this->options->getLanguage();
217 - $table = new MessageTable( $this->collection, $this->group, $code );
 215+ $table = new MessageTable( $this->collection, $this->group );
218216 $table->appendEditLinkParams( 'loadtask', $this->getId() );
219217 $table->setReviewMode();
220218
Index: trunk/extensions/Translate/utils/MessageTable.php
@@ -13,9 +13,8 @@
1414 */
1515 class MessageTable {
1616 protected $reviewMode = false;
17 - protected $collection = null;
18 - protected $group = null;
19 - protected $code = null;
 17+ protected $collection;
 18+ protected $group;
2019 protected $editLinkParams = array();
2120
2221 protected $headers = array(
@@ -24,22 +23,18 @@
2524 'default' => array( 'msg', 'allmessagesdefault' ),
2625 );
2726
28 - public function __construct( MessageCollection $collection, MessageGroup $group, $code ) {
 27+ public function __construct( MessageCollection $collection, MessageGroup $group ) {
2928 $this->collection = $collection;
3029 $this->group = $group;
31 - $this->code = $code;
3230 $this->setHeaderText( 'table', $group->getLabel() );
3331 $this->appendEditLinkParams( 'loadgroup', $group->getId() );
3432 }
3533
36 - /**
37 - * @param $array array
38 - */
3934 public function setEditLinkParams( array $array ) {
4035 $this->editLinkParams = $array;
4136 }
4237
43 - public function appendEditLinkParams( $key, $value ) {
 38+ public function appendEditLinkParams( /*string*/ $key, /*string*/ $value ) {
4439 $this->editLinkParams[$key] = $value;
4540 }
4641
@@ -105,10 +100,6 @@
106101
107102 $optional = wfMsgHtml( 'translate-optional' );
108103
109 - $mlang = Language::factory( $this->code );
110 - $mespa = array( 'dir' => $mlang->getDir(), 'lang' => $this->code );
111 - unset( $mlang );
112 -
113104 $batch = new LinkBatch();
114105 if ( method_exists( $batch, 'setCaller' ) ) {
115106 $batch->setCaller( __METHOD__ );
@@ -122,6 +113,9 @@
123114
124115 $batch->execute();
125116
 117+ $sourceLang = Language::factory( $this->group->getSourceLanguage() );
 118+ $targetLang = Language::factory( $this->collection->getLanguage() );
 119+
126120 $output = '';
127121 $this->collection->initMessages(); // Just to be sure
128122 foreach ( $this->collection as $key => $m ) {
@@ -129,13 +123,15 @@
130124 $title = $this->keyToTitle( $key );
131125
132126 $original = $m->definition();
133 - # @todo Handle directionality of fallback language(s)
134 - if ( $m->translation() ) {
 127+
 128+ if ( $m->translation() !== null ) {
135129 $message = $m->translation();
136 - $rclasses = array_merge ( $mespa, array( 'class' => 'translated' ) );
 130+ $rclasses = self::getLanguageAttributes( $targetLang );
 131+ $rclasses['class'] = 'translated';
137132 } else {
138133 $message = $original;
139 - $rclasses = array( 'lang' => 'en', 'dir' => 'ltr', 'class' => 'untranslated' );
 134+ $rclasses = self::getLanguageAttributes( $sourceLang );
 135+ $rclasses['class'] = 'untranslated';
140136 }
141137
142138 global $wgLang;
@@ -209,4 +205,16 @@
210206
211207 return Title::makeTitle( $namespace, $titleText );
212208 }
 209+
 210+ protected static function getLanguageAttributes( Language $language ) {
 211+ global $wgTranslateDocumentationLanguageCode;
 212+ $code = $language->getCode();
 213+ $dir = $language->getDir();
 214+ if ( $code === $wgTranslateDocumentationLanguageCode ) {
 215+ // Should be good enough for now
 216+ $code = 'en';
 217+ }
 218+
 219+ return array( 'lang' => $code, 'dir' => $dir );
 220+ }
213221 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r99392Fix for r99379nikerabbit08:07, 10 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81168Partial solution of bug 27022 (user proper directionality in message lists) -...purodha21:41, 28 January 2011

Status & tagging log