Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
TranslationStats.php
Go to the documentation of this file.
1<?php
13
33 public static function getPercentageTranslated( $group, $languages, $threshold = false,
34 $simple = false
35 ) {
36 $stats = [];
37
38 $g = MessageGroups::singleton()->getGroup( $group );
39
40 $collection = $g->initCollection( 'en' );
41 foreach ( $languages as $code ) {
42 $collection->resetForNewLanguage( $code );
43 // Initialise messages
44 $collection->filter( 'ignored' );
45 $collection->filter( 'optional' );
46 // Store the count of real messages for later calculation.
47 $total = count( $collection );
48 $collection->filter( 'translated', false );
49 $translated = count( $collection );
50
51 $translatedPercentage = ( $translated * 100 ) / $total;
52 if ( $translatedPercentage >= $threshold ) {
53 if ( $simple ) {
54 $stats[] = $code;
55 } else {
56 $stats[$code] = $translatedPercentage;
57 }
58 }
59 }
60
61 return $stats;
62 }
63}
Factory class for accessing message groups individually by id or all of them as a list.
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.