Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
14 | 14 | */ |
15 | 15 | |
16 | | -define( 'TRANSLATE_VERSION', '2010-01-04' ); |
| 16 | +define( 'TRANSLATE_VERSION', '2010-01-16' ); |
17 | 17 | |
18 | 18 | $wgExtensionCredits['specialpage'][] = array( |
19 | 19 | 'path' => __FILE__, |
Index: trunk/extensions/Translate/README |
— | — | @@ -34,11 +34,15 @@ |
35 | 35 | } |
36 | 36 | </code> |
37 | 37 | |
| 38 | +== Changes in ??? == |
| 39 | +* 2010-01-16 Translation memory suggestions are aggregated intelligently to save space |
| 40 | + There is link back to the original message in tm suggestions |
| 41 | + tm-export superceded dump-tm |
| 42 | + |
38 | 43 | == Changes in version 12 == |
39 | 44 | - Page translation |
40 | 45 | - New fuzzy system, should be faster now |
41 | 46 | - Edit are consistently filled when starting translation |
42 | | -- ??? |
43 | 47 | |
44 | 48 | == Changes in version 11 == |
45 | 49 | * 2009-05-09 |
Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -133,13 +133,13 @@ |
134 | 134 | global $wgTranslateTM; |
135 | 135 | if ( $wgTranslateTM === false ) return null; |
136 | 136 | if ( !$this->targetLanguage ) return null; |
| 137 | + if ( strval( $this->getDefinition() ) === '' ) return null; |
137 | 138 | |
138 | 139 | // Needed data |
139 | 140 | $code = $this->targetLanguage; |
140 | 141 | $definition = $this->getDefinition(); |
| 142 | + $ns = $this->title->getNsText(); |
141 | 143 | |
142 | | - $boxes = array(); |
143 | | - |
144 | 144 | // Fetch suggestions |
145 | 145 | $server = $wgTranslateTM['server']; |
146 | 146 | $port = $wgTranslateTM['port']; |
— | — | @@ -148,24 +148,45 @@ |
149 | 149 | $url = "$server:$port/tmserver/en/$code/unit/$def"; |
150 | 150 | $suggestions = Http::get( $url, $timeout ); |
151 | 151 | |
| 152 | + $sugFields = array(); |
152 | 153 | // Parse suggestions, but limit to three (in case there would be more) |
153 | 154 | if ( $suggestions !== false ) { |
154 | 155 | $suggestions = json_decode( $suggestions, true ); |
155 | | - $suggestions = array_slice( $suggestions, 0, 3 ); |
156 | 156 | foreach ( $suggestions as $s ) { |
157 | | - $label = wfMsgHtml( 'translate-edit-tmmatch' , sprintf( '%.2f', $s['quality'] ) ); |
| 157 | + // No use to suggest them what they are currently viewing |
| 158 | + if ( $s['context'] === "$ns:{$this->page}" ) continue; |
| 159 | + |
| 160 | + $accuracy = wfMsgHtml( 'translate-edit-tmmatch' , sprintf( '%.2f', $s['quality'] ) ); |
| 161 | + $legend = array( $accuracy => array() ); |
| 162 | + |
158 | 163 | $source_page = Title::newFromText( $s['context'] . "/$code" ); |
159 | 164 | if ( $source_page ) { |
160 | | - $label = self::editLink( $source_page, |
161 | | - htmlspecialchars( $label ), array( 'action' => 'edit' ) |
162 | | - ); |
| 165 | + $legend[$accuracy][] = self::editLink( $source_page, '•' ); |
163 | 166 | } |
| 167 | + |
164 | 168 | $text = TranslateUtils::convertWhiteSpaceToHTML( $s['target'] ); |
165 | 169 | $params = array( 'class' => 'mw-sp-translate-edit-tmsug', 'title' => $s['source'] ); |
166 | | - $boxes[] = Html::rawElement( 'div', $params, self::legend( $label ) . $text . self::clear() ); |
| 170 | + |
| 171 | + if ( isset( $sugFields[$s['target']] ) ) { |
| 172 | + $sugFields[$s['target']][2] = array_merge_recursive( $sugFields[$s['target']][2], $legend ); |
| 173 | + } else { |
| 174 | + $sugFields[$s['target']] = array( $text, $params, $legend ); |
| 175 | + } |
167 | 176 | } |
| 177 | + |
| 178 | + $boxes = array(); |
| 179 | + foreach( $sugFields as $field ) { |
| 180 | + list( $text, $params, $label ) = $field; |
| 181 | + $legend = array(); |
| 182 | + foreach ( $label as $acc => $links ) { $legend[] = $acc . ' ' . implode( " ", $links ); } |
| 183 | + $legend = implode( ' | ', $legend ); |
| 184 | + $boxes[] = Html::rawElement( 'div', $params, self::legend( $legend ) . $text . self::clear() ); |
| 185 | + } |
168 | 186 | } |
169 | 187 | |
| 188 | + // Limit to three max |
| 189 | + $boxes = array_slice( $boxes, 0, 3 ); |
| 190 | + |
170 | 191 | // Enclose if there is more than one box |
171 | 192 | if ( count( $boxes ) ) { |
172 | 193 | $sep = Html::element( 'hr', array( 'class' => 'mw-translate-sep' ) ); |
— | — | @@ -259,9 +280,7 @@ |
260 | 281 | |
261 | 282 | $target = Title::makeTitleSafe( $ns, "$page/$fbcode" ); |
262 | 283 | if ( $target ) { |
263 | | - $label = self::editLink( $target, |
264 | | - htmlspecialchars( $label ), array( 'action' => 'edit' ) |
265 | | - ); |
| 284 | + $label = self::editLink( $target, htmlspecialchars( $label ) ); |
266 | 285 | } |
267 | 286 | |
268 | 287 | $text = TranslateUtils::convertWhiteSpaceToHTML( $text ); |
— | — | @@ -290,7 +309,7 @@ |
291 | 310 | $ns = $this->title->getNamespace(); |
292 | 311 | |
293 | 312 | $title = Title::makeTitle( $ns, $page . '/' . $wgTranslateDocumentationLanguageCode ); |
294 | | - $edit = self::editLink( $title, wfMsgHtml( 'translate-edit-contribute' ), array( 'action' => 'edit' ) ); |
| 313 | + $edit = self::editLink( $title, wfMsgHtml( 'translate-edit-contribute' ) ); |
295 | 314 | $info = TranslateUtils::getMessageContent( $page, $wgTranslateDocumentationLanguageCode, $ns ); |
296 | 315 | |
297 | 316 | $class = 'mw-sp-translate-edit-info'; |
— | — | @@ -431,10 +450,15 @@ |
432 | 451 | return TranslateUtils::fieldset( $title, Html::element( 'span', null, $msg ), $attributes ); |
433 | 452 | } |
434 | 453 | |
435 | | - |
436 | 454 | public static function editLink( $target, $text, $params = array() ) { |
437 | 455 | global $wgUser; |
438 | 456 | |
| 457 | + list( $page, ) = self::figureMessage( $target ); |
| 458 | + $group = TranslateUtils::messageKeyToGroup( $target->getNamespace(), $page ); |
| 459 | + if ( $group ) $group = MessageGroups::getGroup( $group ); |
| 460 | + $params += array( 'action' => 'edit' ); |
| 461 | + if ( $group ) $params += array( 'loadgroup' => $group->getId() ); |
| 462 | + |
439 | 463 | $jsEdit = TranslationEditPage::jsEdit( $target ); |
440 | 464 | |
441 | 465 | return $wgUser->getSkin()->link( $target, $text, $jsEdit, $params ); |