Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 1 | <?php |
| 2 | require_once('common.php'); |
| 3 | print_head(); |
| 4 | |
| 5 | if (isset($_REQUEST['upload']) && is_uploaded_file($_FILES['langfile']['tmp_name'])) { |
| 6 | $lang = 'upload'; |
| 7 | $phrases = parselangfile($_FILES['langfile']['tmp_name']); |
| 8 | $languageinfo[$lang]['name'] = $_FILES['langfile']['name']; |
| 9 | } |
| 10 | else { |
| 11 | $lang = isset($_GET['lang']) ? $_GET['lang'] : ''; |
Jonas Häggqvist | 492a7b6 | 2011-06-05 10:57:52 +0000 | [diff] [blame] | 12 | $phrases = parselangfile(sprintf('rockbox/apps/lang/%s.lang', $lang)); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | if ($phrases === false) die("This language doesn't exist, you bad man!"); |
Frank Gevaerts | f6a9d68 | 2012-04-04 21:26:38 +0200 | [diff] [blame] | 16 | $english = parselangfile('rockbox/apps/lang/english.lang'); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 17 | |
| 18 | if ($lang == 'english') { |
| 19 | echo <<<MOO |
| 20 | <img class="flag" src="flags/150/{$languageinfo[$lang]['flag']}.png" /> |
| 21 | <h1>Potential problems in {$languageinfo[$lang]['name']} language</h1> |
| 22 | <p>The English language file is perfect. Don't taunt it.</p> |
| 23 | <p>Go <a href=".">back</a>.</p> |
| 24 | MOO; |
| 25 | print_foot(); |
| 26 | die(); |
| 27 | } |
| 28 | echo <<<MOO |
| 29 | <img class="flag" src="flags/150/{$languageinfo[$lang]['flag']}.png" /> |
| 30 | <h1>Potential problems in {$languageinfo[$lang]['name']} language</h1> |
| 31 | <p>Go <a href=".">back</a>.</p> |
| 32 | <p>This page will help identify potential problems in your language file. I |
| 33 | don't offer a way to fix this automatically, so you'll have to edit the language |
| 34 | file by hand. Hopefully this page will still be of some help. Note that not all |
| 35 | of these lines have to be actual problems, so pay attention to what you do.</p> |
| 36 | MOO; |
| 37 | |
| 38 | $strings = array(); |
| 39 | foreach($english as $id => $phrase) { |
| 40 | if (!isset($phrases[$id])) { |
| 41 | $strings[] = sprintf("<strong>%s</strong>: Missing translation entirely<br />\n", |
| 42 | $id |
| 43 | ); |
| 44 | } |
| 45 | else { |
| 46 | foreach($phrase['source'] as $target => $value) { |
| 47 | if (!isset($phrases[$id]['dest'][$target]) && $value != 'none' && $value != '') { |
| 48 | $strings[] = sprintf("<strong>%s</strong>: Missing target \"%s\"<br />\n", |
| 49 | $id, $target |
| 50 | ); |
| 51 | } |
| 52 | elseif ( |
| 53 | ($phrases[$id]['dest'][$target] == 'none' || $phrases[$id]['dest'][$target] == '') |
| 54 | && |
| 55 | ($value != 'none' && $value != '')) { |
| 56 | $strings[] = sprintf("<strong>%s:%s</strong>: Set to \"%s\", but English sets \"%s\"<br />\n", |
| 57 | $id, $target, $phrases[$id]['dest'][$target], $value |
| 58 | ); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | if (sizeof($strings) > 0) { |
| 64 | print("<h2>Missing strings/targets</h2>\n"); |
| 65 | print("<p>This is an error that should be fixed</p>\n"); |
| 66 | print(join($strings, '')); |
| 67 | } |
| 68 | |
| 69 | $strings = array(); |
| 70 | foreach($phrases as $id => $phrase) { |
| 71 | foreach(array("dest", "voice") as $what) { |
| 72 | foreach($phrase[$what] as $target => $value) { |
| 73 | if (isset($english[$id][$what][$target]) |
| 74 | && ($english[$id][$what][$target] == '' || $english[$id][$what][$target] == "none") |
| 75 | && trim($value) != trim($english[$id][$what][$target]) |
| 76 | ) { |
| 77 | $strings[] = sprintf("<strong>%s:%s - %s</strong>: Empty string doesn't match English (set to: %s - should be: %s)<br />\n", |
| 78 | $id, |
| 79 | $target, |
| 80 | $what, |
| 81 | $value == '' ? '""' : $value, |
| 82 | $english[$id][$what][$target] |
| 83 | ); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | if (sizeof($strings) > 0) { |
| 89 | print("<h2>Wrong empty strings</h2>"); |
| 90 | 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"); |
| 91 | print(join($strings, '')); |
| 92 | } |
| 93 | |
| 94 | $strings = array(); |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 95 | $ignoreidentical = explode("\n", |
| 96 | "LANG_SERIAL_BITRATE_19200 |
| 97 | LANG_SERIAL_BITRATE_9600 |
| 98 | LANG_SERIAL_BITRATE_38400 |
| 99 | LANG_SERIAL_BITRATE_57600 |
| 100 | LANG_COMPRESSOR_RATIO_10 |
| 101 | LANG_COMPRESSOR_RATIO_2 |
| 102 | LANG_COMPRESSOR_RATIO_6 |
| 103 | LANG_COMPRESSOR_RATIO_4 |
| 104 | LANG_ROCKBOX_TITLE |
| 105 | LANG_EQUALIZER_BAND_Q |
| 106 | LANG_COLOR_RGB_LABELS |
| 107 | LANG_BYTE |
| 108 | VOICE_ZERO |
| 109 | VOICE_ONE |
| 110 | VOICE_TWO |
| 111 | VOICE_THREE |
| 112 | VOICE_FOUR |
| 113 | VOICE_FIVE |
| 114 | VOICE_SIX |
| 115 | VOICE_SEVEN |
| 116 | VOICE_EIGHT |
| 117 | VOICE_NINE |
| 118 | VOICE_TEN |
| 119 | VOICE_ELEVEN |
| 120 | VOICE_TWELVE |
| 121 | VOICE_THIRTEEN |
| 122 | VOICE_FOURTEEN |
| 123 | VOICE_FIFTEEN |
| 124 | VOICE_SIXTEEN |
| 125 | VOICE_SEVENTEEN |
| 126 | VOICE_EIGHTEEN |
| 127 | VOICE_NINETEEN |
| 128 | VOICE_TWENTY |
| 129 | VOICE_THIRTY |
| 130 | VOICE_FORTY |
| 131 | VOICE_FIFTY |
| 132 | VOICE_SIXTY |
| 133 | VOICE_SEVENTY |
| 134 | VOICE_EIGHTY |
| 135 | VOICE_NINETY |
| 136 | VOICE_CHAR_A |
| 137 | VOICE_CHAR_B |
| 138 | VOICE_CHAR_C |
| 139 | VOICE_CHAR_D |
| 140 | VOICE_CHAR_E |
| 141 | VOICE_CHAR_F |
| 142 | VOICE_CHAR_G |
| 143 | VOICE_CHAR_H |
| 144 | VOICE_CHAR_I |
| 145 | VOICE_CHAR_J |
| 146 | VOICE_CHAR_K |
| 147 | VOICE_CHAR_L |
| 148 | VOICE_CHAR_M |
| 149 | VOICE_CHAR_N |
| 150 | VOICE_CHAR_O |
| 151 | VOICE_CHAR_P |
| 152 | VOICE_CHAR_Q |
| 153 | VOICE_CHAR_R |
| 154 | VOICE_CHAR_S |
| 155 | VOICE_CHAR_T |
| 156 | VOICE_CHAR_U |
| 157 | VOICE_CHAR_V |
| 158 | VOICE_CHAR_W |
| 159 | VOICE_CHAR_X |
| 160 | VOICE_CHAR_Y |
| 161 | VOICE_CHAR_Z |
| 162 | VOICE_PAUSE"); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 163 | foreach($phrases as $id => $phrase) { |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 164 | if (in_array($id, $ignoreidentical)) { |
| 165 | continue; |
| 166 | } |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 167 | foreach($phrase['source'] as $target => $value) { |
| 168 | if ($phrase['source'][$target] == $phrase['dest'][$target] |
| 169 | && $phrase['source'][$target] != 'none' |
| 170 | && $phrase['source'][$target] != '' |
| 171 | ) { |
| 172 | $strings[] = sprintf("<strong>%s:%s</strong>: English and translation are the same (\"%s\")<br />\n", |
| 173 | $id, |
| 174 | $target, |
| 175 | $value |
| 176 | ); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | if (sizeof($strings) > 0) { |
| 181 | print("<h2>Identical English and translation</h2>"); |
| 182 | printf("<p>Doesn't have to be a problem, if the string is valid in the %s language</p>\n", $languageinfo[$lang]['name']); |
| 183 | print(join($strings, '')); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | $strings = array(); |
| 188 | foreach($english as $id => $phrase) { |
| 189 | foreach($phrase['source'] as $target => $value) { |
| 190 | if (($phrases[$id]['voice'][$target] == '' |
| 191 | || $phrases[$id]['voice'][$target] == 'none') |
| 192 | && $phrase['voice'][$target] != '' |
| 193 | && $phrase['voice'][$target] != 'none' |
| 194 | ) { |
| 195 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice missing (english voice: \"%s\")<br />\n", |
| 196 | $id, |
| 197 | $target, |
| 198 | $phrase['voice'][$target] |
| 199 | ); |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | if (sizeof($strings) > 0) { |
| 204 | print("<h2>Missing voice strings</h2>"); |
| 205 | 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']); |
| 206 | print(join($strings, '')); |
| 207 | } |
| 208 | |
| 209 | $strings = array(); |
| 210 | foreach($phrases as $id => $phrase) { |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 211 | if (in_array($id, $ignoreidentical)) { |
| 212 | continue; |
| 213 | } |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 214 | foreach($phrase['source'] as $target => $value) { |
| 215 | if ($phrase['voice'][$target] == $value && $value != '' && $value != 'none') { |
| 216 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice and source are the same (\"%s\")<br />\n", |
| 217 | $id, |
| 218 | $target, |
| 219 | $value |
| 220 | ); |
| 221 | } |
| 222 | elseif ($english[$id]['voice'][$target] == $phrase['voice'][$target] |
| 223 | && $english[$id]['voice'][$target] != 'none' |
| 224 | && $english[$id]['voice'][$target] != '' |
| 225 | ) { |
| 226 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice and English voice are the same (\"%s\")<br />\n", |
| 227 | $id, |
| 228 | $target, |
| 229 | $english[$id]['voice'][$target] |
| 230 | ); |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | if (sizeof($strings) > 0) { |
| 235 | print("<h2>Same voice and source</h2>"); |
| 236 | printf("<p>Doesn't have to be a problem, if the string is valid in the %s language</p>\n", $languageinfo[$lang]['name']); |
| 237 | print(join($strings, '')); |
| 238 | } |
| 239 | |
Frank Gevaerts | f6a9d68 | 2012-04-04 21:26:38 +0200 | [diff] [blame] | 240 | print("<!--\n"); |
| 241 | print_r($english); |
| 242 | print("\n-->\n"); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 243 | |
| 244 | $strings = array(); |
| 245 | foreach($phrases as $id => $phrase) { |
| 246 | foreach($phrase['voice'] as $target => $value) { |
| 247 | if (!isset($english[$id]['voice'][$target]) |
| 248 | && $value != "" |
| 249 | && $value != "none" |
| 250 | ) { |
| 251 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice not defined for English (set to: \"%s\")<br />\n", |
| 252 | $id, |
| 253 | $target, |
| 254 | $value |
| 255 | ); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | if (sizeof($strings) > 0) { |
| 260 | print("<h2>Unnecessary voice strings</h2>"); |
| 261 | print("<p>These strings are unnecessary, since they're not defined in the English language file. They should probably be removed</p>\n"); |
| 262 | print(join($strings, '')); |
| 263 | } |
| 264 | |
| 265 | if (true || $_SERVER['REMOTE_ADDR'] == trim(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/homeip'))) { |
| 266 | echo <<<MOO |
| 267 | <h2>Check your work in progress</h2> |
| 268 | <p>Using the form below, you can upload a work in progress and generate a report |
| 269 | similar to this one, for your language.</p> |
| 270 | <form enctype="multipart/form-data" action="problems.php" method="post"> |
| 271 | <input type="hidden" name="upload" value="true" /> |
| 272 | <input type="file" name="langfile" /> |
| 273 | <input type="submit" value="send" /> |
| 274 | </form> |
| 275 | MOO; |
| 276 | } |
| 277 | |
| 278 | print_foot(); |
| 279 | ?> |