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