Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -1240,7 +1240,7 @@ |
1241 | 1241 | * @return string |
1242 | 1242 | * @since 2011-12-12 |
1243 | 1243 | */ |
1244 | | - public static function getPriority( MessageGroup $group ) { |
| 1244 | + public static function getPriority( $group ) { |
1245 | 1245 | static $groups = null; |
1246 | 1246 | if ( $groups === null ) { |
1247 | 1247 | $groups = array(); |
— | — | @@ -1255,7 +1255,11 @@ |
1256 | 1256 | } |
1257 | 1257 | } |
1258 | 1258 | |
1259 | | - $id = $group->getId(); |
| 1259 | + if ( $group instanceof MessageGroup ) { |
| 1260 | + $id = $group->getId(); |
| 1261 | + } else { |
| 1262 | + $id = $group; |
| 1263 | + } |
1260 | 1264 | return isset( $groups[$id] ) ? $groups[$id] : ''; |
1261 | 1265 | } |
1262 | 1266 | |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -137,6 +137,10 @@ |
138 | 138 | |
139 | 139 | $wgHooks['LinkBegin'][] = 'SpecialMyLanguage::linkfix'; |
140 | 140 | |
| 141 | +// Stats table manipulation |
| 142 | +$wgHooks['Translate:MessageGroupStats:isIncluded'][] = 'TranslateHooks::hideDiscouragedFromStats'; |
| 143 | +$wgHooks['Translate:MessageGroupStats:isIncluded'][] = 'TranslateHooks::hideRestrictedFromStats'; |
| 144 | + |
141 | 145 | // New rights |
142 | 146 | $wgAvailableRights[] = 'translate'; |
143 | 147 | $wgAvailableRights[] = 'translate-import'; |
Index: trunk/extensions/Translate/TranslateHooks.php |
— | — | @@ -390,5 +390,24 @@ |
391 | 391 | return true; |
392 | 392 | } |
393 | 393 | |
| 394 | + /// Hook: Translate:MessageGroupStats:isIncluded |
| 395 | + public static function hideDiscouragedFromStats( $id, $code ) { |
| 396 | + // Return true to keep, false to exlude |
| 397 | + return MessageGroups::getPriority( $id ) !== 'discouraged'; |
| 398 | + } |
| 399 | + |
| 400 | + /// Hook: Translate:MessageGroupStats:isIncluded |
| 401 | + public static function hideRestrictedFromStats( $id, $code ) { |
| 402 | + $filterLangs = TranslateMetadata::get( $id, 'prioritylangs' ); |
| 403 | + if ( strlen( $filterLangs ) === 0 ) { |
| 404 | + // No restrictions, keep everything |
| 405 | + return true; |
| 406 | + } |
| 407 | + |
| 408 | + $filter = array_flip( explode( ',', $filterLangs ) ); |
| 409 | + // If the language is in the list, return true to not hide it |
| 410 | + return isset( $filter[$code] ); |
| 411 | + } |
| 412 | + |
394 | 413 | } |
395 | 414 | |
Index: trunk/extensions/Translate/utils/StatsTable.php |
— | — | @@ -299,13 +299,11 @@ |
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | | - $filterLangs = TranslateMetadata::get( $groupId , 'prioritylangs' ); |
304 | | - if ( strlen( $filterLangs ) > 0 ) { |
305 | | - $filter = array_flip( explode( ',', $filterLangs ) ); |
306 | | - if ( count( $filter ) > 0 && !isset( $filter[$code] ) ) { |
307 | | - $blacklisted = true; |
308 | | - } |
| 303 | + $include = wfRunHooks( 'Translate:MessageGroupStats:isIncluded', array( $groupId, $code ) ); |
| 304 | + if ( !$include ) { |
| 305 | + $blacklisted = true; |
309 | 306 | } |
| 307 | + |
310 | 308 | return $blacklisted; |
311 | 309 | } |
312 | 310 | |
Index: trunk/extensions/Translate/utils/MessageGroupStats.php |
— | — | @@ -257,7 +257,9 @@ |
258 | 258 | if ( !isset( $stats[$sid][$code] ) ) { |
259 | 259 | $stats[$sid][$code] = self::forItemInternal( $stats, $subgroup, $code ); |
260 | 260 | } |
261 | | - if ( MessageGroups::getPriority( $subgroup ) !== 'discouraged' ) { |
| 261 | + |
| 262 | + $include = wfRunHooks( 'Translate:MessageGroupStats:isIncluded', array( $sid, $code ) ); |
| 263 | + if ( $include ) { |
262 | 264 | $aggregates = self::multiAdd( $aggregates, $stats[$sid][$code] ); |
263 | 265 | } |
264 | 266 | } |
Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php |
— | — | @@ -362,12 +362,6 @@ |
363 | 363 | return ''; |
364 | 364 | } |
365 | 365 | |
366 | | - # These are hidden, and the code in MessageGroupStats makes sure that |
367 | | - # these are not counted in the aggregate groups they may belong. |
368 | | - if ( MessageGroups::getPriority( $group ) === 'discouraged' ) { |
369 | | - return ''; |
370 | | - } |
371 | | - |
372 | 366 | $stats = $cache[$groupId]; |
373 | 367 | |
374 | 368 | list( $total, $translated, $fuzzy ) = $stats; |