Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/lib_general.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ function nav_languages($lang = null)
$out .= '<li><a href="/revcheck.php?p=misstags&amp;lang='.$lang.'">Missing revision numbers</a></li>';
$out .= '<li><a href="/revcheck.php?p=missfiles&amp;lang='.$lang.'">Untranslated files</a></li>';
$out .= '<li><a href="/revcheck.php?p=oldfiles&amp;lang='.$lang.'">Not in EN tree</a></li>';
$out .= '<li><a href="/revcheck.php?p=brokenfiles&amp;lang='.$lang.'">Broken XML</a></li>';
$out .= '<li><a href="/revcheck.php?p=donottranslate&amp;lang='.$lang.'">Do not translate</a></li>';
$out .= '</ul>';
}
$out .= '</li>';
Expand Down
46 changes: 45 additions & 1 deletion include/lib_revcheck.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@
'RevTagProblem' => 'No revision tag',
'NotInEnTree' => 'Not in EN tree',
'Untranslated' => 'Available for translation',
'XmlBroken' => 'Broken XML',
'DoNotTranslate' => 'Marked do not translate',
];

// Files marked do not translate are never expected to be translated, so
// they are listed but never counted against a translation. This matches
// the totals of doc-base scripts/revcheck.php and genrevdb.php.
$TRANSLATION_STATUSES_OFF_TOTAL = [ 'DoNotTranslate' ];

function get_language_intro($idx, $lang) {
$result = $idx->query("SELECT intro FROM languages WHERE lang = '$lang'");
$answer = $result->fetchArray();
Expand Down Expand Up @@ -161,6 +168,40 @@ function get_oldfiles($idx, $lang)
return $tmp;
}

function get_brokenfiles($idx, $lang)
{
$sql = <<<SQL
SELECT path AS dir, name AS name, xmlError AS error, size / 1024 AS size
FROM files
WHERE lang = '{$lang}' AND status = 'XmlBroken'
ORDER BY dir, name
SQL;

$result = $idx->query($sql);
$tmp = array();
while ($r = $result->fetchArray(SQLITE3_ASSOC)) {
$tmp[] = $r;
}
return $tmp;
}

function get_donottranslate($idx, $lang)
{
$sql = <<<SQL
SELECT path AS dir, name AS name, size / 1024 AS size
FROM files
WHERE lang = '{$lang}' AND status = 'DoNotTranslate'
ORDER BY dir, name
SQL;

$result = $idx->query($sql);
$tmp = array();
while ($r = $result->fetchArray(SQLITE3_ASSOC)) {
$tmp[] = $r;
}
return $tmp;
}

function get_misstags($idx, $lang)
{
$sql = <<<SQL
Expand Down Expand Up @@ -221,9 +262,12 @@ function get_lang_stats($idx, $lang) {
$stats = [];
$total = [ 'total' => 0, 'size' => 0 ];

global $TRANSLATION_STATUSES_OFF_TOTAL;

while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$stats[$row['status']] = $row;
if ($row['status'] != 'NotInEnTree') {
if ($row['status'] != 'NotInEnTree'
&& !in_array($row['status'], $TRANSLATION_STATUSES_OFF_TOTAL)) {
$total['total'] += $row['total'];
$total['size'] += $row['size'];
}
Expand Down
66 changes: 64 additions & 2 deletions www/revcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,63 @@
echo gen_date($DBLANG);
break;

case 'brokenfiles':
$brokenfiles = get_brokenfiles($dbhandle, $lang);

if (!$brokenfiles) {
echo '<p>Good, all translated files are valid XML.</p>';
} else {
$num = count($brokenfiles);
echo '<p>These files do not parse as XML. The manual build may fail, or silently ';
echo 'drop their contents, so they need a fix before anything else.</p>';
echo '<table class="c">';
echo '<tr><th>Broken XML files ('.$num.' files):</th><th>Error</th><th>kB</th></tr>';

$last_dir = false;
foreach ($brokenfiles as $row) {
if (!$last_dir || $last_dir != $row['dir']) {
echo '<tr><th colspan="3">'.htmlspecialchars($row['dir']).'</th></tr>';
$last_dir = $row['dir'];
}
echo '<tr>',
'<td>', htmlspecialchars($row['name']), '</td>',
'<td>', htmlspecialchars($row['error']), '</td>',
'<td>', $row['size'], '</td>',
'</tr>';
}
echo '</table>';
}
echo gen_date($DBLANG);
break;

case 'donottranslate':
$donottranslate = get_donottranslate($dbhandle, $lang);

if (!$donottranslate) {
echo '<p>No source file is marked do not translate.</p>';
} else {
$num = count($donottranslate);
echo '<p>These English files carry a <code>&lt;?do-not-translate?&gt;</code> mark. They are ';
echo 'not expected to be translated, and are left out of the totals of this translation.</p>';
echo '<table class="c">';
echo '<tr><th>Marked do not translate ('.$num.' files):</th><th>kB</th></tr>';

$last_dir = false;
foreach ($donottranslate as $row) {
if (!$last_dir || $last_dir != $row['dir']) {
echo '<tr><th colspan="2">'.htmlspecialchars($row['dir']).'</th></tr>';
$last_dir = $row['dir'];
}
echo '<tr>',
'<td>', htmlspecialchars($row['name']), '</td>',
'<td>', $row['size'], '</td>',
'</tr>';
}
echo '</table>';
}
echo gen_date($DBLANG);
break;

case 'misstags':
$misstags = get_misstags($dbhandle, $lang);

Expand Down Expand Up @@ -211,16 +268,21 @@
echo '<tr><th>File status type</th><th>Number of files</th><th>Percent of files</th><th>Size of files (kB)</th><th>Percent of size</th></tr>';

foreach ($TRANSLATION_STATUSES as $status => $description) {
// A status kept out of the total has no meaningful share of it.
$offTotal = in_array($status, $TRANSLATION_STATUSES_OFF_TOTAL);

echo
'<tr>',
'<td>', $description, '</td>',
'<td>', $stats[$status]['total'] ?? 0, '</td>',
'<td>',
sprintf('%.2f%%', 100 * (($stats[$status]['total'] ?? 0) / $stats['total']['total'])),
$offTotal ? 'n/a'
: sprintf('%.2f%%', 100 * (($stats[$status]['total'] ?? 0) / $stats['total']['total'])),
'</td>',
'<td>', $stats[$status]['size'] ?? 0, '</td>',
'<td>',
sprintf('%.2f%%', 100 * (($stats[$status]['size'] ?? 0) / $stats['total']['size'])),
$offTotal ? 'n/a'
: sprintf('%.2f%%', 100 * (($stats[$status]['size'] ?? 0) / $stats['total']['size'])),
'</td>',
'</tr>';
}
Expand Down