blob: 949004583e8e8591838a61553c04075634bc72bd [file] [log] [blame]
<?php
require_once('common.php');
print_head();
if (isset($_REQUEST['upload']) && is_uploaded_file($_FILES['langfile']['tmp_name'])) {
$lang = 'upload';
$phrases = parselangfile($_FILES['langfile']['tmp_name']);
$languageinfo[$lang]['name'] = $_FILES['langfile']['name'];
}
else {
$lang = isset($_GET['lang']) ? $_GET['lang'] : '';
$phrases = parselangfile(sprintf('apps/lang/%s.lang', $lang));
}
if ($phrases === false) die("This language doesn't exist, you bad man!");
$english = parselangfile('apps/lang/english.lang');
if ($lang == 'english') {
echo <<<MOO
<img class="flag" src="flags/150/{$languageinfo[$lang]['flag']}.png" />
<h1>Potential problems in {$languageinfo[$lang]['name']} language</h1>
<p>The English language file is perfect. Don't taunt it.</p>
<p>Go <a href=".">back</a>.</p>
MOO;
print_foot();
die();
}
echo <<<MOO
<img class="flag" src="flags/150/{$languageinfo[$lang]['flag']}.png" />
<h1>Potential problems in {$languageinfo[$lang]['name']} language</h1>
<p>Go <a href=".">back</a>.</p>
<p>This page will help identify potential problems in your language file. I
don't offer a way to fix this automatically, so you'll have to edit the language
file by hand. Hopefully this page will still be of some help. Note that not all
of these lines have to be actual problems, so pay attention to what you do.</p>
MOO;
$strings = array();
foreach($english as $id => $phrase) {
if (!isset($phrases[$id])) {
$strings[] = sprintf("<strong>%s</strong>: Missing translation entirely<br />\n",
$id
);
}
else {
foreach($phrase['source'] as $target => $value) {
if (!isset($phrases[$id]['dest'][$target]) && $value != 'none' && $value != '') {
$strings[] = sprintf("<strong>%s</strong>: Missing target \"%s\"<br />\n",
$id, $target
);
}
elseif (
($phrases[$id]['dest'][$target] == 'none' || $phrases[$id]['dest'][$target] == '')
&&
($value != 'none' && $value != '')) {
$strings[] = sprintf("<strong>%s:%s</strong>: Set to \"%s\", but English sets \"%s\"<br />\n",
$id, $target, $phrases[$id]['dest'][$target], $value
);
}
}
}
}
if (sizeof($strings) > 0) {
print("<h2>Missing strings/targets</h2>\n");
print("<p>This is an error that should be fixed</p>\n");
print(join($strings, ''));
}
$strings = array();
foreach($phrases as $id => $phrase) {
foreach(array("dest", "voice") as $what) {
foreach($phrase[$what] as $target => $value) {
if (isset($english[$id][$what][$target])
&& ($english[$id][$what][$target] == '' || $english[$id][$what][$target] == "none")
&& trim($value) != trim($english[$id][$what][$target])
) {
$strings[] = sprintf("<strong>%s:%s - %s</strong>: Empty string doesn't match English (set to: %s - should be: %s)<br />\n",
$id,
$target,
$what,
$value == '' ? '""' : $value,
$english[$id][$what][$target]
);
}
}
}
}
if (sizeof($strings) > 0) {
print("<h2>Wrong empty strings</h2>");
print("<p>When the English language is set to \"\" or none, the translation should follow. The strings below don't do this. This is an error and should be fixed.</p>\n");
print(join($strings, ''));
}
$strings = array();
foreach($phrases as $id => $phrase) {
foreach($phrase['source'] as $target => $value) {
if ($phrase['source'][$target] == $phrase['dest'][$target]
&& $phrase['source'][$target] != 'none'
&& $phrase['source'][$target] != ''
) {
$strings[] = sprintf("<strong>%s:%s</strong>: English and translation are the same (\"%s\")<br />\n",
$id,
$target,
$value
);
}
}
}
if (sizeof($strings) > 0) {
print("<h2>Identical English and translation</h2>");
printf("<p>Doesn't have to be a problem, if the string is valid in the %s language</p>\n", $languageinfo[$lang]['name']);
print(join($strings, ''));
}
$strings = array();
foreach($english as $id => $phrase) {
foreach($phrase['source'] as $target => $value) {
if (($phrases[$id]['voice'][$target] == ''
|| $phrases[$id]['voice'][$target] == 'none')
&& $phrase['voice'][$target] != ''
&& $phrase['voice'][$target] != 'none'
) {
$strings[] = sprintf("<strong>%s:%s</strong>: Voice missing (english voice: \"%s\")<br />\n",
$id,
$target,
$phrase['voice'][$target]
);
}
}
}
if (sizeof($strings) > 0) {
print("<h2>Missing voice strings</h2>");
printf("<p>This is almost certainly a mistake unless the string does not make sense in the %s language, and should be fixed before it's possible to generate meaningful voicefiles for the %s language.</p>\n", $languageinfo[$lang]['name'], $languageinfo[$lang]['name']);
print(join($strings, ''));
}
$strings = array();
foreach($phrases as $id => $phrase) {
foreach($phrase['source'] as $target => $value) {
if ($phrase['voice'][$target] == $value && $value != '' && $value != 'none') {
$strings[] = sprintf("<strong>%s:%s</strong>: Voice and source are the same (\"%s\")<br />\n",
$id,
$target,
$value
);
}
elseif ($english[$id]['voice'][$target] == $phrase['voice'][$target]
&& $english[$id]['voice'][$target] != 'none'
&& $english[$id]['voice'][$target] != ''
) {
$strings[] = sprintf("<strong>%s:%s</strong>: Voice and English voice are the same (\"%s\")<br />\n",
$id,
$target,
$english[$id]['voice'][$target]
);
}
}
}
if (sizeof($strings) > 0) {
print("<h2>Same voice and source</h2>");
printf("<p>Doesn't have to be a problem, if the string is valid in the %s language</p>\n", $languageinfo[$lang]['name']);
print(join($strings, ''));
}
$strings = array();
foreach($phrases as $id => $phrase) {
foreach($phrase['voice'] as $target => $value) {
if (!isset($english[$id]['voice'][$target])
&& $value != ""
&& $value != "none"
) {
$strings[] = sprintf("<strong>%s:%s</strong>: Voice not defined for English (set to: \"%s\")<br />\n",
$id,
$target,
$value
);
}
}
}
if (sizeof($strings) > 0) {
print("<h2>Unnecessary voice strings</h2>");
print("<p>These strings are unnecessary, since they're not defined in the English language file. They should probably be removed</p>\n");
print(join($strings, ''));
}
if (true || $_SERVER['REMOTE_ADDR'] == trim(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/homeip'))) {
echo <<<MOO
<h2>Check your work in progress</h2>
<p>Using the form below, you can upload a work in progress and generate a report
similar to this one, for your language.</p>
<form enctype="multipart/form-data" action="problems.php" method="post">
<input type="hidden" name="upload" value="true" />
<input type="file" name="langfile" />
<input type="submit" value="send" />
</form>
MOO;
}
print_foot();
?>