Language File Checker
This will report missing or untranslated strings in the language files.
\n";
while (!feof($in))
{
$line = fgets($in);
$token_match = "";
if (preg_match(PATTERN_START, $line, $matches))
{
// DEBUG print "| $matches[1] | ".key($ref_statements);
$token_match = $matches[1];
if (!array_key_exists($token_match, $ref_statements))
{
fwrite($out, "// REMOVED - ".$line);
continue;
}
while (($token_match != key($ref_statements)) &&
(!array_key_exists(key($ref_statements), $vocab)))
{
if (array_key_exists(key($ref_statements), $seen))
{
break;
}
$seen[key($ref_statements)] = 1;
fwrite($out, current($ref_statements));
$added[] = htmlspecialchars(key($ref_statements));
$ret = next($ref_statements);
// DEBUG print " ".key($ref_statements);
if (!$ret)
{
break;
}
}
next($ref_statements);
}
$seen[$token_match] = 1;
fwrite($out, $line);
// DEBUG print " |
\n";
}
fclose($in);
fclose($out);
// DEBUG print "\n";
if (count($added))
{
print "Added the following tokens:\n\n- ".
implode("
\n- ",$added)."
\n
\n";
rename("$path_to_mrbs/$langs$l", "$path_to_mrbs/$langs$l.old") or
die("Failed to rename $path_to_mrbs/$langs$l to $path_to_mrbs/$langs$l.old");
rename("$path_to_mrbs/$langs$l.new", "$path_to_mrbs/$langs$l") or
die("Failed to rename $path_to_mrbs/$langs$l.new to $path_to_mrbs/$langs$l");
// Re-read the updated file
unset($vocab);
include "$path_to_mrbs/$langs$l";
}
else
{
print "No token lines added.";
unlink("$path_to_mrbs/$langs$l.new") or
print "
Failed to delete $path_to_mrbs/$langs".htmlspecialchars($l).".new.\n";
}
}
?>
Language:
| Problem |
Key |
Value |
$val)
{
$ntotal++;
$status = "";
if (!isset($vocab[$key]))
{
$nmissing++;
$status = "Missing";
} else if (($key != "charset") &&
($vocab[$key] == $ref[$key]) &&
($ref[$key] != "") &&
(!preg_match('/^mail_/', $key)))
{
$status = "Untranslated";
$nunxlate++;
}
if ($status != "")
{
echo " | $status | " .
htmlspecialchars($key) . " | " .
htmlspecialchars($ref[$key]) . " |
\n";
}
}
echo "
\n";
echo "Total entries in reference language file: $ntotal\n";
echo "
For language file $l: ";
if ($nmissing + $nunxlate == 0)
{
echo "no missing or untranslated entries.\n";
}
else
{
echo "missing: $nmissing, untranslated: $nunxlate.\n";
}
print "
\n";
}
?>