4 * @subpackage Maintenance
6 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * Output is posted from time to time on:
10 * http://meta.wikimedia.org/wiki/Localization_statistics
14 require_once('commandLine.inc');
17 $dir = opendir("$IP/languages");
18 while ($file = readdir($dir)) {
19 if (preg_match("/Language(.*?)\.php$/", $file, $m)) {
27 foreach($langs as $key => $lang) {
28 if ($lang == 'Utf8' ||
$lang == '' ||
$lang == 'Converter')
34 foreach($langs as $lang) {
35 // Since they aren't loaded by default..
36 require_once( 'languages/Language' . $lang . '.php' );
37 $arr = 'wgAllMessages' . $lang;
38 if (@is_array
($
$arr)) { // Some of them don't have a message array
39 $msgs[$wgContLang->lcfirst($lang)] = array(
40 'total' => count($
$arr),
41 'redundant' => redundant($
$arr),
44 $msgs[$wgContLang->lcfirst($lang)] = array(
52 $out = "{| border=2 cellpadding=4 cellspacing=0 style=\"background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;\" width=100%\n";
54 $out .= li('Language', true);
55 $out .= li('Translated', true);
56 $out .= li('%', true);
57 $out .= li('Untranslated', true);
58 $out .= li('%', true);
59 $out .= li('Redundant', true);
60 $out .= li('%', true);
63 // generate table rows using wikisyntax
64 foreach($msgs as $lang => $stats) {
66 $out .= li($wgContLang->getLanguageName(strtr($lang, '_', '-')) . " ($lang)"); // Language
67 $out .= li($stats['total'] . '/' . $msgs['en']['total']); // Translated
68 $out .= li(percent($stats['total'], $msgs['en']['total'])); // % Translated
69 $out .= li($msgs['en']['total'] - $stats['total']); // Untranslated
70 $out .= li(percent($msgs['en']['total'] - $stats['total'], $msgs['en']['total'])); // % Untranslated
71 $out .= li($stats['redundant'] . '/' . $stats['total']); // Redundant
72 $out .= li(percent($stats['redundant'], $stats['total'])); // % Redundant
75 $out = substr($out, 0, -3) . "|}\n";
78 function beginul() { return ''; }
79 function endul() { return "|-\n"; }
80 function li($in, $heading = false) { return ($heading ?
'!' : '|') . " $in\n"; }
81 function percent($subset, $total, $accuracy = 2) { return @sprintf
( '%.' . $accuracy . 'f%%', 100 * $subset / $total ); }
83 // FIXME: This takes an obscene amount of time
84 function redundant(&$arr) {
85 global $wgAllMessagesEn;
88 foreach(array_keys($arr) as $key) {
89 if ( ! array_key_exists( $key, $wgAllMessagesEn) )