';
$languages = array();
foreach ($otherLangs as $l) {
if (is_dir($f)) continue;
$stats['en']['files'] += 1;
$s = sprintf('
%s %s | ',
$langs[$l], $l);
$cols = '';
foreach ($enFiles as $f) {
$langF = str_replace('.en.lang', '.' . $l . '.lang', $f);
$langF = $l . substr($langF, 2);
$link = str_replace(array('en/', '.en.lang', 'index'), '', $f);
$dest_l = sprintf('%s/%s/%s/%s', APP_ROOT, $l, $link, 'index.php');
$dest_en = sprintf('%s/%s/%s/%s', APP_ROOT, 'en', $link, 'index.php');
// if symlink e.g. does directly translated page exist?
if ((realpath($dest_l) == realpath($dest_en))) {
$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);
}
if (file_exists($langF)) {
$stats[$l]['files'] += 1;
$test = _lang_diff($f, $langF);
$num_of_untranslated_strings = count($test['notrans']);
if ($link == 'about/constitution') {
$dest_constitution = sprintf('%s/%s/%s/%s_%s.md', APP_ROOT, $l, 'about/constitution', 'mageia.org_statutes', $l);
if ($l == 'en') {
$strings_en_constitution = count(array_unique(file($dest_constitution)));
}
$test['a'] += $strings_en_constitution; // add aproximate number of strings from constitution to translate
if(!is_readable($dest_constitution) || $l == 'en') {
$num_of_untranslated_strings += $strings_en_constitution; // add constitution strings as not translated
}
}
if ($link == 'downloads/get') {
$link = sprintf('view download OK page view non existing file page', $l, $link, $l, $link);
} else {
$link = sprintf('view page%s', $l, $link, $page_not_linked);
}
if (count($test['missing']) === 0
&& $num_of_untranslated_strings === 0) {
$extra = null;
if (count($test['extra']) > 0) {
$extra = ' ' . sprintf($diff_link, $f, $l) . '+' . count($test['extra']) . '';
}
$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 {
$cols .= sprintf('' . $diff_link,
$f, $l);
if (count($test['missing']) > 0) {
$cols .= count($test['missing']) . ' missing ';
}
if ($num_of_untranslated_strings > 0) {
$cols .= $num_of_untranslated_strings . ' untranslated ';
}
if (count($test['extra']) > 0) {
$cols .= count($test['extra']) . ' extra';
}
$cols .= '';
$cols .= $link . ' | ';
$done = $test['a'] - $num_of_untranslated_strings - count($test['missing']);
}
}
$stats[$l]['strings'] += $done;
} else {
$stats[$l]['files'] += 0;
$stats[$l]['strings'] += 0;
$cols .= sprintf('add translation%s | ',
$f, $l, $old_page
);
}
}
$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 .= '
---|
';
$languages[$progress . '-' . $l] = $s;
}
$en_language = array_shift($languages); // shift English for proper sorting
krsort($languages, SORT_NUMERIC);
array_unshift($languages, $en_language); // unshift English back
$s = implode($languages);
$enFiles = array_map(function ($e) { return str_replace('en/', '', $e); }, $enFiles);
$thfiles = '
' . implode(' | ', $enFiles) . ' | ';
$count = count($otherLangs);
echo <<
{$count} languages |
Progress |
{$thfiles}
{$s}
S;
?>