';
$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);
if (file_exists($langF)) {
$stats[$l]['files'] += 1;
$link = str_replace(array('en/', '.en.lang', 'index'), '', $f);
$link = sprintf('view page', $l, $link);
$test = _lang_diff($f, $langF);
if (count($test['missing']) === 0
&& count($test['notrans']) === 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 .= '' . count($test['notrans']) . ' 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 (count($test['notrans']) > 0) {
$cols .= count($test['notrans']) . ' untranslated ';
}
if (count($test['extra']) > 0) {
$cols .= count($test['extra']) . ' extra';
}
$cols .= '';
$cols .= $link . ' | ';
$done = $test['a'] - count($test['notrans']) - count($test['missing']);
}
}
$stats[$l]['strings'] += $done;
} else {
$stats[$l]['files'] += 0;
$stats[$l]['strings'] += 0;
$old_link = str_replace(array('en/', '.en.lang', 'index'), '', $f);
// if symlink e.g. does directly translated page exist?
if (is_link('./../' . $l . '/' . $old_link)) {
$old_link = '';
} else {
$old_link = sprintf('by recycling old page', $l, $old_link);
}
$cols .= sprintf('add translation%s | ',
$f, $l, $old_link
);
}
}
$progress = floor($stats[$l]['strings'] / $stats['en']['strings'] * 100);
$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;
?>