www.mageia.org translation report

'; $languages = array(); $unique_lines_in_eng_constitution = array(); $number_of_unique_lines_in_eng_constitution = 0; foreach ($otherLangs as $l) { $stats['en']['files'] += 1; $stats[$l]['files'] = 0; $stats[$l]['strings'] = 0; if ($l == 'en' || $restore_languages) { $link_one_language = '%s'; } else { $link_one_language = '%s'; } $s = sprintf('' . $link_one_language . '
%s', $langs[$l], $l); $cols = ''; $lang_coloumn = ''; foreach ($enFiles as $f) { if (strrpos($f, '.pot')) { $gettext = true; $resource = _extract_resource($f); $langF = _po_file_switch($f, $l); } else { $gettext = false; $resource = _extract_resource($f, '.en.lang'); $langF = _lang_file_switch($f, $l); } $enStringsCount[$f] = 0; if (false !== strstr($f, '../_nav/langs/en.')) { $nav = true; $langF = '../_nav/langs/' . $l . '.po' . (($l == 'en') ? 't' : ''); } else { $nav = false; } $link = str_replace('index', '', $resource); if ($nav) { $dest_en = sprintf('%s/%s/%s', G_APP_ROOT, '_nav/langs', 'en.pot'); $dest_l = sprintf('%s/%s/%s', G_APP_ROOT, '_nav/langs', $l . '.po'); } else { $dest_en = sprintf('%s/%s/%s/%s', G_APP_ROOT, 'en', $link, 'index.php'); $dest_l = sprintf('%s/%s/%s/%s', G_APP_ROOT, $l, $link, 'index.php'); } $times[] = time_debug('pre realpath ' . $f); // if symlink e.g. does directly translated page exist? if ((realpath($dest_l) == realpath($dest_en)) || $nav) { $page_not_linked = ''; $old_page = ''; } else { $page_not_linked = sprintf('old page still exists!', $l, $link); $old_page = sprintf('by recycling old page', $l, $link); } $times[] = time_debug('post realpath'); $add_translation = sprintf('add translation%s', $f, $l, $old_page ); if (file_exists($langF)) { $times[] = time_debug('file_exists'); $stats[$l]['files'] += 1; if ($gettext) { $test = _po_diff($l, $resource); $num_of_missing_strings = 0; $num_of_fuzzy_or_missing_strings = count($test['fuzzy_or_missing']); } else { $test = _lang_diff($f, $langF); $num_of_missing_strings = count($test['missing']); $num_of_fuzzy_or_missing_strings = 0; } $times[] = time_debug('_diff ' . $l . ' '. $f); $num_of_untranslated_strings = count($test['notrans']); $num_of_duplicated_strings = count($test['dup_str']); $num_of_extra_strings = count($test['extra']); if ($link == 'about/constitution') { $constitution_results = aproximate_number_of_untranslated_constitution_lines(G_APP_ROOT, $l, $unique_lines_in_eng_constitution); if ($l == 'en') { $unique_lines_in_eng_constitution = $constitution_results['unique_lines_in_constitution']; $number_of_unique_lines_in_eng_constitution = count($unique_lines_in_eng_constitution); } $test['a'] += $number_of_unique_lines_in_eng_constitution; // add aproximate number of lines from constitution to translate $num_of_untranslated_strings += $constitution_results['aproximate_number_of_untranslated_lines']; } $times[] = time_debug('aproximate_number_of_untranslated_constitution_lines'); if ($link == 'about/license') { require_once('../en/about/license/license.php'); $times[] = time_debug('require_once ' . $l); $license_array = read_license_from_vcs($l); $license_numbers = array_pop($license_array); $test['a'] += $license_numbers["all"]; // add aproximate number of untranslated sentences from license $num_of_untranslated_strings += $license_numbers["untran"]; // add number of all license sentences } $times[] = time_debug('read_license_from_vcs ' . $l); if ($nav) { $mga = array(); $local_f = @file_get_contents('../_nav/langs/' . $l . '.po'); $times[] = time_debug('local_f ' . $l); $mognas_f = @file_get_contents('http://nav.mageia.org/langs/' . $l . '.po'); $times[] = time_debug('mognas_f ' . $l); if ($local_f != $mognas_f) { $page_not_linked = 'difference in svn 1 & 2'; } } else if ($link == 'downloads/get') { $mga = array( 'A' => 'downloads/get/index.php?q=Mageia-2-dual-CD.iso&d=1', // " style="display: block; 'B' => 'downloads/get/index.php?q=Non_existing_file&d=1', ); } else if ($link == '2') { $mga = array( 'A' => '2/index.php', 'B' => '2/download_index.php', 'C' => '2/for-pc/index.php', 'D' => '2/for-server/index.php', ); } else if ($link == '3') { $mga = array( 'A' => '3/index.php', 'B' => '3/download_index.php', 'C' => '3/for-pc/index.php', 'D' => '3/for-server/index.php', ); } else if ($link == '4') { $mga = array( 'A' => '4/index.php', 'B' => '4/download_index.php', ); } else if ($link == 'cauldron') { $mga = array( 'view page' => '5/download_index.php', ); } else if ($link == 'documentation') { $mga = array( 'doc' => 'doc/index.php', 'archive' => 'doc/archive.php', ); } else { $mga = array( 'view page' => $link, ); } $link = '
'; foreach ($mga as $k => $v) { $link .= sprintf('%s', $l, $v, $k); } $link .= $page_not_linked . '
'; if ($num_of_missing_strings === 0 && $num_of_fuzzy_or_missing_strings === 0 && $num_of_untranslated_strings === 0) { $extra = null; if ($num_of_extra_strings > 0) { $extra = ' ' . sprintf($diff_link, $f, $l) . '+' . $num_of_extra_strings . ''; } if ($num_of_duplicated_strings > 0) { $extra .= ' ' . sprintf($diff_link, $f, $l) . 'dup: ' . $num_of_duplicated_strings . ''; } $cols .= sprintf('OK%s%s', $langF, $extra, $link); $done = $test['a']; } else { // special case, en if ($l == 'en') { $cols .= '' . $num_of_untranslated_strings . ' strings'; $enStringsCount[$f] += $test['a']; $done = $test['a']; // regular case } else { if(($num_of_missing_strings + $num_of_fuzzy_or_missing_strings + $num_of_untranslated_strings) < $test['a']) { $cols .= sprintf('' . $diff_link, $f, $l); if ($num_of_missing_strings > 0) { $cols .= $num_of_missing_strings . ' missing
'; } if ($num_of_fuzzy_or_missing_strings > 0) { $cols .= $num_of_fuzzy_or_missing_strings . ' fuzzy or missing
'; } if ($num_of_untranslated_strings > 0) { $cols .= $num_of_untranslated_strings . ' untranslated
'; } if ($num_of_extra_strings > 0) { $cols .= $num_of_extra_strings . ' extra
'; } if ($num_of_duplicated_strings > 0) { $cols .= $num_of_duplicated_strings . ' duplicate'; $cols .= ($num_of_duplicated_strings > 1 ? 's' : ''); } $cols .= ''; $cols .= $link . ''; } else { $cols .= $add_translation; } $done = $test['a'] - $num_of_untranslated_strings - $num_of_missing_strings - $num_of_fuzzy_or_missing_strings; } } $stats[$l]['strings'] += $done; } else { $cols .= $add_translation; } $num_clmns_to_repeat = 9; $num_of_col++; if ($num_of_col % $num_clmns_to_repeat == 0 && $num_of_col <= $num_of_enFiles - ($num_clmns_to_repeat / 3)) { if ($l == 'en') { $cols .= $lang_coloumn = 'Language'; } else { $cols .= $lang_coloumn = sprintf('' . $link_one_language . '
%s', $langs[$l], $l); } } } $cols .= $lang_coloumn; // last coloumn $num_of_col = 0; // reset counter of coloumns $times[] = time_debug('progress'); $progress = floor($stats[$l]['strings'] / $stats['en']['strings'] * 100); // special case, en if ($l == 'en') { $s .= sprintf('%d strings', $stats[$l]['strings']); // regular case } else { $s .= sprintf( '%d%%
%d / %d', $progress, $stats[$l]['strings'], $stats['en']['strings'] ); } $s .= $cols; $s .= '' . PHP_EOL; $languages[$stats[$l]['strings'] . '-' . $l] = $s; } $en_language = array_shift($languages); // shift English for proper sorting krsort($languages, SORT_NUMERIC); $times[] = time_debug('krsort'); // add language coloumn repeating $lang_line = array(); $num_of_h_col = 0; $add_last_coloumn = FALSE; $resources = ($restore_resources ? ' ' : $num_of_enFiles . ' resources'); foreach ($enFiles as $lang_chunk) { $num_of_h_col++; if ($restore_resources) { $lang_line[] = str_replace('en/', '', $lang_chunk); } else { $lang_line[] = '' . str_replace('en/', '', $lang_chunk) . ''; } if ($num_of_h_col % $num_clmns_to_repeat == 0 && $num_of_h_col <= $num_of_enFiles - ($num_clmns_to_repeat / 3)) { $lang_line[] = $resources; $add_last_coloumn = TRUE; } } if ($add_last_coloumn) { $lang_line[] = $resources;// last h coloumn } $thfiles = '' . implode('', $lang_line) . '' . PHP_EOL; if ($restore_languages) { echo '

Restore all languages.

'; $count = ' '; } else { $count = count($otherLangs) . ' languages'; } if ($restore_resources) { echo '

Restore all resources.

'; } $chunks = array_chunk($languages, $num_lines_to_repeat = 8); // add header repeating $table_body = array(); $times[] = time_debug('table_body'); foreach ($chunks as $chunk) { $table_body = array_merge($table_body, $chunk, array(count($chunk) > ($num_lines_to_repeat / 2) ? '' . $count . '' . $resources . '' . $thfiles : '')); } array_unshift($table_body, $en_language); // unshift English back $s = implode($table_body); echo << {$count} Progress {$thfiles} {$s}
S; /* START OF DEBUG LINES */ $times[] = time_debug('end_time'); $sum = 0; $read_license_from_vcs_ = array(); $mognas_f_ = array(); $_diff_ = array(); foreach ($times as $time) { if($time[1] >= 0.01) { $snails[] = array($time[0], $time[1]); $sum += $time[1]; $pos = strpos($time[0], 'read_license_from_vcs'); if ($pos !== false) { $read_license_from_vcs_[] = array($time[0], $time[1]); } $pos = strpos($time[0], 'mognas_f'); if ($pos !== false) { $mognas_f_[] = array($time[0], $time[1]); } $pos = strpos($time[0], '_diff'); if ($pos !== false) { $_diff_[] = array($time[0], $time[1]); } } if ($time[0] == 'end_time') { $end = $time[2]; } } $snails_time = 0; $read_license_from_vcs_time = array(); $mognas_f_time = array(); $_diff_time = array(); foreach ($read_license_from_vcs_ as $part) { $read_license_from_vcs_time[] = $part[1]; } $snails_time += $read_license_from_vcs_time_sum = array_sum($read_license_from_vcs_time); foreach ($mognas_f_ as $part) { $mognas_f_time[] = $part[1]; } $snails_time += $mognas_f_time_sum = array_sum($mognas_f_time); foreach ($_diff_ as $part) { $_diff_time[] = $part[1]; } $snails_time += $_diff_time_sum = array_sum($_diff_time); // read_license_from_vcs, mognas_f, _diff //print_r($read_license_from_vcs_) . '
' . PHP_EOL; //print_r($mognas_f_) . '
' . PHP_EOL; //print_r($_diff_) . '
' . PHP_EOL; echo '
' . PHP_EOL;

echo  '
' .'rlv: '; print_r($read_license_from_vcs_time_sum) . '
' . PHP_EOL; echo '
' .'mog: '; print_r($mognas_f_time_sum) . '
' . PHP_EOL; echo '
' .'dif: '; print_r($_diff_time_sum) . '
' . PHP_EOL; echo '
' .'Sst: '; print_r($snails_time) . '
' . PHP_EOL; echo '
' .'sum: '; print_r($sum) . '
' . PHP_EOL; echo '
' .'end: '; print_r($end) . '
' . PHP_EOL; echo '
' .'rel: ' . number_format(100 * $sum/$end, 1) . ' %
' . PHP_EOL; /*echo '
' .'snails: ' . PHP_EOL; print_r($snails) . PHP_EOL; echo 'times: ' . PHP_EOL; print_r($times) . PHP_EOL; /**/ echo '
' . PHP_EOL; /* END OF DEBUG LINES */ ?>