Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
TranslationStats.php
Go to the documentation of this file.
1<?php
31 public static function getPercentageTranslated( $group, $languages, $threshold = false,
32 $simple = false
33 ) {
34 $stats = [];
35
36 $g = MessageGroups::singleton()->getGroup( $group );
37
38 $collection = $g->initCollection( 'en' );
39 foreach ( $languages as $code ) {
40 $collection->resetForNewLanguage( $code );
41 // Initialise messages
42 $collection->filter( 'ignored' );
43 $collection->filter( 'optional' );
44 // Store the count of real messages for later calculation.
45 $total = count( $collection );
46 $collection->filter( 'translated', false );
47 $translated = count( $collection );
48
49 $translatedPercentage = ( $translated * 100 ) / $total;
50 if ( $translatedPercentage >= $threshold ) {
51 if ( $simple ) {
52 $stats[] = $code;
53 } else {
54 $stats[$code] = $translatedPercentage;
55 }
56 }
57 }
58
59 return $stats;
60 }
61}
Contains methods that provide statistics for message groups.
static getPercentageTranslated( $group, $languages, $threshold=false, $simple=false)
Returns translated percentage for message group in given languages.