Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 1 | <?php |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 2 | /************************************************************************ |
| 3 | * __________ __ ___. |
| 4 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | * \/ \/ \/ \/ \/ |
| 9 | * Copyright (C) 2010 Jonas Häggqvist |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License |
| 13 | * as published by the Free Software Foundation; either version 2 |
| 14 | * of the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 17 | * KIND, either express or implied. |
| 18 | * |
| 19 | **************************************************************************/ |
| 20 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 21 | require_once('common.php'); |
| 22 | print_head(); |
| 23 | |
Frank Gevaerts | 065257f | 2013-02-16 13:36:05 +0100 | [diff] [blame] | 24 | $languageinfo = languageinfo(); |
| 25 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 26 | if (isset($_REQUEST['upload']) && is_uploaded_file($_FILES['langfile']['tmp_name'])) { |
| 27 | $lang = 'upload'; |
| 28 | $phrases = parselangfile($_FILES['langfile']['tmp_name']); |
| 29 | $languageinfo[$lang]['name'] = $_FILES['langfile']['name']; |
| 30 | } |
| 31 | else { |
| 32 | $lang = isset($_GET['lang']) ? $_GET['lang'] : ''; |
Jonas Häggqvist | 492a7b6 | 2011-06-05 10:57:52 +0000 | [diff] [blame] | 33 | $phrases = parselangfile(sprintf('rockbox/apps/lang/%s.lang', $lang)); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | if ($phrases === false) die("This language doesn't exist, you bad man!"); |
Frank Gevaerts | f6a9d68 | 2012-04-04 21:26:38 +0200 | [diff] [blame] | 37 | $english = parselangfile('rockbox/apps/lang/english.lang'); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 38 | |
| 39 | if ($lang == 'english') { |
| 40 | echo <<<MOO |
| 41 | <img class="flag" src="flags/150/{$languageinfo[$lang]['flag']}.png" /> |
| 42 | <h1>Potential problems in {$languageinfo[$lang]['name']} language</h1> |
| 43 | <p>The English language file is perfect. Don't taunt it.</p> |
| 44 | <p>Go <a href=".">back</a>.</p> |
| 45 | MOO; |
| 46 | print_foot(); |
| 47 | die(); |
| 48 | } |
| 49 | echo <<<MOO |
| 50 | <img class="flag" src="flags/150/{$languageinfo[$lang]['flag']}.png" /> |
| 51 | <h1>Potential problems in {$languageinfo[$lang]['name']} language</h1> |
| 52 | <p>Go <a href=".">back</a>.</p> |
| 53 | <p>This page will help identify potential problems in your language file. I |
| 54 | don't offer a way to fix this automatically, so you'll have to edit the language |
| 55 | file by hand. Hopefully this page will still be of some help. Note that not all |
| 56 | of these lines have to be actual problems, so pay attention to what you do.</p> |
| 57 | MOO; |
| 58 | |
| 59 | $strings = array(); |
| 60 | foreach($english as $id => $phrase) { |
| 61 | if (!isset($phrases[$id])) { |
| 62 | $strings[] = sprintf("<strong>%s</strong>: Missing translation entirely<br />\n", |
| 63 | $id |
| 64 | ); |
| 65 | } |
| 66 | else { |
| 67 | foreach($phrase['source'] as $target => $value) { |
| 68 | if (!isset($phrases[$id]['dest'][$target]) && $value != 'none' && $value != '') { |
| 69 | $strings[] = sprintf("<strong>%s</strong>: Missing target \"%s\"<br />\n", |
| 70 | $id, $target |
| 71 | ); |
| 72 | } |
| 73 | elseif ( |
| 74 | ($phrases[$id]['dest'][$target] == 'none' || $phrases[$id]['dest'][$target] == '') |
| 75 | && |
| 76 | ($value != 'none' && $value != '')) { |
| 77 | $strings[] = sprintf("<strong>%s:%s</strong>: Set to \"%s\", but English sets \"%s\"<br />\n", |
| 78 | $id, $target, $phrases[$id]['dest'][$target], $value |
| 79 | ); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | if (sizeof($strings) > 0) { |
| 85 | print("<h2>Missing strings/targets</h2>\n"); |
| 86 | print("<p>This is an error that should be fixed</p>\n"); |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 87 | print(join($strings, '')); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | $strings = array(); |
| 91 | foreach($phrases as $id => $phrase) { |
| 92 | foreach(array("dest", "voice") as $what) { |
| 93 | foreach($phrase[$what] as $target => $value) { |
| 94 | if (isset($english[$id][$what][$target]) |
| 95 | && ($english[$id][$what][$target] == '' || $english[$id][$what][$target] == "none") |
| 96 | && trim($value) != trim($english[$id][$what][$target]) |
| 97 | ) { |
Solomon Peachy | 7cb0b9e | 2020-07-26 11:18:44 -0400 | [diff] [blame] | 98 | $strings[] = sprintf("<strong>%s:%s - %s</strong>: Empty string doesn't match English (set to: '%s' - should be: '%s')<br />\n", |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 99 | $id, |
| 100 | $target, |
| 101 | $what, |
| 102 | $value == '' ? '""' : $value, |
| 103 | $english[$id][$what][$target] |
| 104 | ); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | if (sizeof($strings) > 0) { |
| 110 | print("<h2>Wrong empty strings</h2>"); |
| 111 | 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"); |
| 112 | print(join($strings, '')); |
| 113 | } |
| 114 | |
| 115 | $strings = array(); |
Solomon Peachy | 5743654 | 2020-07-28 15:24:00 -0400 | [diff] [blame] | 116 | |
| 117 | $ignoreidentical = explode("\n", file_get_contents("rockbox/tools/langignorelist.txt")); |
| 118 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 119 | foreach($phrases as $id => $phrase) { |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 120 | if (in_array($id, $ignoreidentical)) { |
| 121 | continue; |
| 122 | } |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 123 | foreach($phrase['source'] as $target => $value) { |
| 124 | if ($phrase['source'][$target] == $phrase['dest'][$target] |
| 125 | && $phrase['source'][$target] != 'none' |
| 126 | && $phrase['source'][$target] != '' |
| 127 | ) { |
| 128 | $strings[] = sprintf("<strong>%s:%s</strong>: English and translation are the same (\"%s\")<br />\n", |
| 129 | $id, |
| 130 | $target, |
| 131 | $value |
| 132 | ); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | if (sizeof($strings) > 0) { |
| 137 | print("<h2>Identical English and translation</h2>"); |
| 138 | printf("<p>Doesn't have to be a problem, if the string is valid in the %s language</p>\n", $languageinfo[$lang]['name']); |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 139 | print(join($strings, '')); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 140 | } |
| 141 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 142 | $strings = array(); |
| 143 | foreach($english as $id => $phrase) { |
| 144 | foreach($phrase['source'] as $target => $value) { |
Solomon Peachy | b6aacc1 | 2020-07-27 17:32:10 -0400 | [diff] [blame] | 145 | if (isset($phrases[$id]) && |
| 146 | ($phrases[$id]['voice'][$target] == '' |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 147 | || $phrases[$id]['voice'][$target] == 'none') |
| 148 | && $phrase['voice'][$target] != '' |
| 149 | && $phrase['voice'][$target] != 'none' |
| 150 | ) { |
| 151 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice missing (english voice: \"%s\")<br />\n", |
| 152 | $id, |
| 153 | $target, |
| 154 | $phrase['voice'][$target] |
| 155 | ); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | if (sizeof($strings) > 0) { |
| 160 | print("<h2>Missing voice strings</h2>"); |
| 161 | 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']); |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 162 | print(join($strings, '')); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | $strings = array(); |
| 166 | foreach($phrases as $id => $phrase) { |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 167 | if (in_array($id, $ignoreidentical)) { |
| 168 | continue; |
| 169 | } |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 170 | foreach($phrase['source'] as $target => $value) { |
| 171 | if ($phrase['voice'][$target] == $value && $value != '' && $value != 'none') { |
| 172 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice and source are the same (\"%s\")<br />\n", |
| 173 | $id, |
| 174 | $target, |
| 175 | $value |
| 176 | ); |
| 177 | } |
| 178 | elseif ($english[$id]['voice'][$target] == $phrase['voice'][$target] |
| 179 | && $english[$id]['voice'][$target] != 'none' |
| 180 | && $english[$id]['voice'][$target] != '' |
| 181 | ) { |
| 182 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice and English voice are the same (\"%s\")<br />\n", |
| 183 | $id, |
| 184 | $target, |
| 185 | $english[$id]['voice'][$target] |
| 186 | ); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | if (sizeof($strings) > 0) { |
| 191 | print("<h2>Same voice and source</h2>"); |
| 192 | printf("<p>Doesn't have to be a problem, if the string is valid in the %s language</p>\n", $languageinfo[$lang]['name']); |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 193 | print(join($strings, '')); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Frank Gevaerts | f6a9d68 | 2012-04-04 21:26:38 +0200 | [diff] [blame] | 196 | print("<!--\n"); |
| 197 | print_r($english); |
| 198 | print("\n-->\n"); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 199 | |
| 200 | $strings = array(); |
| 201 | foreach($phrases as $id => $phrase) { |
| 202 | foreach($phrase['voice'] as $target => $value) { |
| 203 | if (!isset($english[$id]['voice'][$target]) |
| 204 | && $value != "" |
| 205 | && $value != "none" |
| 206 | ) { |
| 207 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice not defined for English (set to: \"%s\")<br />\n", |
| 208 | $id, |
| 209 | $target, |
| 210 | $value |
| 211 | ); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | if (sizeof($strings) > 0) { |
| 216 | print("<h2>Unnecessary voice strings</h2>"); |
| 217 | print("<p>These strings are unnecessary, since they're not defined in the English language file. They should probably be removed</p>\n"); |
| 218 | print(join($strings, '')); |
| 219 | } |
| 220 | |
| 221 | if (true || $_SERVER['REMOTE_ADDR'] == trim(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/homeip'))) { |
| 222 | echo <<<MOO |
| 223 | <h2>Check your work in progress</h2> |
| 224 | <p>Using the form below, you can upload a work in progress and generate a report |
| 225 | similar to this one, for your language.</p> |
| 226 | <form enctype="multipart/form-data" action="problems.php" method="post"> |
| 227 | <input type="hidden" name="upload" value="true" /> |
| 228 | <input type="file" name="langfile" /> |
| 229 | <input type="submit" value="send" /> |
| 230 | </form> |
| 231 | MOO; |
| 232 | } |
| 233 | |
| 234 | print_foot(); |
| 235 | ?> |