diff --git a/include/lib_general.inc.php b/include/lib_general.inc.php index 1b7ced9..af48826 100644 --- a/include/lib_general.inc.php +++ b/include/lib_general.inc.php @@ -100,6 +100,8 @@ function nav_languages($lang = null) $out .= '
  • Missing revision numbers
  • '; $out .= '
  • Untranslated files
  • '; $out .= '
  • Not in EN tree
  • '; + $out .= '
  • Broken XML
  • '; + $out .= '
  • Do not translate
  • '; $out .= ''; } $out .= ''; diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php index 882452b..7cf8479 100644 --- a/include/lib_revcheck.inc.php +++ b/include/lib_revcheck.inc.php @@ -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(); @@ -161,6 +168,40 @@ function get_oldfiles($idx, $lang) return $tmp; } +function get_brokenfiles($idx, $lang) +{ + $sql = <<query($sql); + $tmp = array(); + while ($r = $result->fetchArray(SQLITE3_ASSOC)) { + $tmp[] = $r; + } + return $tmp; +} + +function get_donottranslate($idx, $lang) +{ + $sql = <<query($sql); + $tmp = array(); + while ($r = $result->fetchArray(SQLITE3_ASSOC)) { + $tmp[] = $r; + } + return $tmp; +} + function get_misstags($idx, $lang) { $sql = << 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']; } diff --git a/www/revcheck.php b/www/revcheck.php index 28e2bc0..7d30004 100644 --- a/www/revcheck.php +++ b/www/revcheck.php @@ -180,6 +180,63 @@ echo gen_date($DBLANG); break; + case 'brokenfiles': + $brokenfiles = get_brokenfiles($dbhandle, $lang); + + if (!$brokenfiles) { + echo '

    Good, all translated files are valid XML.

    '; + } else { + $num = count($brokenfiles); + echo '

    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.

    '; + echo ''; + echo ''; + + $last_dir = false; + foreach ($brokenfiles as $row) { + if (!$last_dir || $last_dir != $row['dir']) { + echo ''; + $last_dir = $row['dir']; + } + echo '', + '', + '', + '', + ''; + } + echo '
    Broken XML files ('.$num.' files):ErrorkB
    '.htmlspecialchars($row['dir']).'
    ', htmlspecialchars($row['name']), '', htmlspecialchars($row['error']), '', $row['size'], '
    '; + } + echo gen_date($DBLANG); + break; + + case 'donottranslate': + $donottranslate = get_donottranslate($dbhandle, $lang); + + if (!$donottranslate) { + echo '

    No source file is marked do not translate.

    '; + } else { + $num = count($donottranslate); + echo '

    These English files carry a <?do-not-translate?> mark. They are '; + echo 'not expected to be translated, and are left out of the totals of this translation.

    '; + echo ''; + echo ''; + + $last_dir = false; + foreach ($donottranslate as $row) { + if (!$last_dir || $last_dir != $row['dir']) { + echo ''; + $last_dir = $row['dir']; + } + echo '', + '', + '', + ''; + } + echo '
    Marked do not translate ('.$num.' files):kB
    '.htmlspecialchars($row['dir']).'
    ', htmlspecialchars($row['name']), '', $row['size'], '
    '; + } + echo gen_date($DBLANG); + break; + case 'misstags': $misstags = get_misstags($dbhandle, $lang); @@ -211,16 +268,21 @@ echo 'File status typeNumber of filesPercent of filesSize of files (kB)Percent of size'; 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 '', '', $description, '', '', $stats[$status]['total'] ?? 0, '', '', - sprintf('%.2f%%', 100 * (($stats[$status]['total'] ?? 0) / $stats['total']['total'])), + $offTotal ? 'n/a' + : sprintf('%.2f%%', 100 * (($stats[$status]['total'] ?? 0) / $stats['total']['total'])), '', '', $stats[$status]['size'] ?? 0, '', '', - sprintf('%.2f%%', 100 * (($stats[$status]['size'] ?? 0) / $stats['total']['size'])), + $offTotal ? 'n/a' + : sprintf('%.2f%%', 100 * (($stats[$status]['size'] ?? 0) / $stats['total']['size'])), '', ''; }