Index: trunk/extensions/Translate/MessageCollection.php |
— | — | @@ -81,6 +81,11 @@ |
82 | 82 | |
83 | 83 | } |
84 | 84 | |
| 85 | + /// @return String |
| 86 | + public function getLanguage() { |
| 87 | + return $this->code; |
| 88 | + } |
| 89 | + |
85 | 90 | // Data setters |
86 | 91 | |
87 | 92 | /** |
Index: trunk/extensions/Translate/TranslateTasks.php |
— | — | @@ -188,8 +188,7 @@ |
189 | 189 | } |
190 | 190 | |
191 | 191 | 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 ); |
194 | 193 | $table->appendEditLinkParams( 'loadtask', $this->getId() ); |
195 | 194 | |
196 | 195 | return $table->fullTable(); |
— | — | @@ -212,8 +211,7 @@ |
213 | 212 | } |
214 | 213 | |
215 | 214 | 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 ); |
218 | 216 | $table->appendEditLinkParams( 'loadtask', $this->getId() ); |
219 | 217 | $table->setReviewMode(); |
220 | 218 | |
Index: trunk/extensions/Translate/utils/MessageTable.php |
— | — | @@ -13,9 +13,8 @@ |
14 | 14 | */ |
15 | 15 | class MessageTable { |
16 | 16 | protected $reviewMode = false; |
17 | | - protected $collection = null; |
18 | | - protected $group = null; |
19 | | - protected $code = null; |
| 17 | + protected $collection; |
| 18 | + protected $group; |
20 | 19 | protected $editLinkParams = array(); |
21 | 20 | |
22 | 21 | protected $headers = array( |
— | — | @@ -24,22 +23,18 @@ |
25 | 24 | 'default' => array( 'msg', 'allmessagesdefault' ), |
26 | 25 | ); |
27 | 26 | |
28 | | - public function __construct( MessageCollection $collection, MessageGroup $group, $code ) { |
| 27 | + public function __construct( MessageCollection $collection, MessageGroup $group ) { |
29 | 28 | $this->collection = $collection; |
30 | 29 | $this->group = $group; |
31 | | - $this->code = $code; |
32 | 30 | $this->setHeaderText( 'table', $group->getLabel() ); |
33 | 31 | $this->appendEditLinkParams( 'loadgroup', $group->getId() ); |
34 | 32 | } |
35 | 33 | |
36 | | - /** |
37 | | - * @param $array array |
38 | | - */ |
39 | 34 | public function setEditLinkParams( array $array ) { |
40 | 35 | $this->editLinkParams = $array; |
41 | 36 | } |
42 | 37 | |
43 | | - public function appendEditLinkParams( $key, $value ) { |
| 38 | + public function appendEditLinkParams( /*string*/ $key, /*string*/ $value ) { |
44 | 39 | $this->editLinkParams[$key] = $value; |
45 | 40 | } |
46 | 41 | |
— | — | @@ -105,10 +100,6 @@ |
106 | 101 | |
107 | 102 | $optional = wfMsgHtml( 'translate-optional' ); |
108 | 103 | |
109 | | - $mlang = Language::factory( $this->code ); |
110 | | - $mespa = array( 'dir' => $mlang->getDir(), 'lang' => $this->code ); |
111 | | - unset( $mlang ); |
112 | | - |
113 | 104 | $batch = new LinkBatch(); |
114 | 105 | if ( method_exists( $batch, 'setCaller' ) ) { |
115 | 106 | $batch->setCaller( __METHOD__ ); |
— | — | @@ -122,6 +113,9 @@ |
123 | 114 | |
124 | 115 | $batch->execute(); |
125 | 116 | |
| 117 | + $sourceLang = Language::factory( $this->group->getSourceLanguage() ); |
| 118 | + $targetLang = Language::factory( $this->collection->getLanguage() ); |
| 119 | + |
126 | 120 | $output = ''; |
127 | 121 | $this->collection->initMessages(); // Just to be sure |
128 | 122 | foreach ( $this->collection as $key => $m ) { |
— | — | @@ -129,13 +123,15 @@ |
130 | 124 | $title = $this->keyToTitle( $key ); |
131 | 125 | |
132 | 126 | $original = $m->definition(); |
133 | | - # @todo Handle directionality of fallback language(s) |
134 | | - if ( $m->translation() ) { |
| 127 | + |
| 128 | + if ( $m->translation() !== null ) { |
135 | 129 | $message = $m->translation(); |
136 | | - $rclasses = array_merge ( $mespa, array( 'class' => 'translated' ) ); |
| 130 | + $rclasses = self::getLanguageAttributes( $targetLang ); |
| 131 | + $rclasses['class'] = 'translated'; |
137 | 132 | } else { |
138 | 133 | $message = $original; |
139 | | - $rclasses = array( 'lang' => 'en', 'dir' => 'ltr', 'class' => 'untranslated' ); |
| 134 | + $rclasses = self::getLanguageAttributes( $sourceLang ); |
| 135 | + $rclasses['class'] = 'untranslated'; |
140 | 136 | } |
141 | 137 | |
142 | 138 | global $wgLang; |
— | — | @@ -209,4 +205,16 @@ |
210 | 206 | |
211 | 207 | return Title::makeTitle( $namespace, $titleText ); |
212 | 208 | } |
| 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 | + } |
213 | 221 | } |