TranslationStats.php

Go to the documentation of this file.
00001 <?php
00017 class TranslationStats {
00031     public static function getPercentageTranslated( $group, $languages, $threshold = false,
00032         $simple = false
00033     ) {
00034         $stats = array();
00035 
00036         $g = MessageGroups::singleton()->getGroup( $group );
00037 
00038         $collection = $g->initCollection( 'en' );
00039         foreach ( $languages as $code ) {
00040             $collection->resetForNewLanguage( $code );
00041             // Initialise messages
00042             $collection->filter( 'ignored' );
00043             $collection->filter( 'optional' );
00044             // Store the count of real messages for later calculation.
00045             $total = count( $collection );
00046             $collection->filter( 'translated', false );
00047             $translated = count( $collection );
00048 
00049             $translatedPercentage = ( $translated * 100 ) / $total;
00050             if ( $translatedPercentage >= $threshold ) {
00051                 if ( $simple ) {
00052                     $stats[] = $code;
00053                 } else {
00054                     $stats[$code] = $translatedPercentage;
00055                 }
00056             }
00057         }
00058 
00059         return $stats;
00060     }
00061 }
Generated on Tue Oct 29 00:00:26 2013 for MediaWiki Translate Extension by  doxygen 1.6.3