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(); |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 116 | $ignoreidentical = explode("\n", |
| 117 | "LANG_SERIAL_BITRATE_19200 |
| 118 | LANG_SERIAL_BITRATE_9600 |
| 119 | LANG_SERIAL_BITRATE_38400 |
| 120 | LANG_SERIAL_BITRATE_57600 |
| 121 | LANG_COMPRESSOR_RATIO_10 |
| 122 | LANG_COMPRESSOR_RATIO_2 |
| 123 | LANG_COMPRESSOR_RATIO_6 |
| 124 | LANG_COMPRESSOR_RATIO_4 |
| 125 | LANG_ROCKBOX_TITLE |
| 126 | LANG_EQUALIZER_BAND_Q |
Solomon Peachy | 38ee3ba | 2020-07-27 13:17:49 -0400 | [diff] [blame] | 127 | LANG_FM_DEFAULT_PRESET_NAME |
| 128 | LANG_DISK_NAME_MMC |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 129 | LANG_COLOR_RGB_LABELS |
| 130 | LANG_BYTE |
Solomon Peachy | 38ee3ba | 2020-07-27 13:17:49 -0400 | [diff] [blame] | 131 | LANG_KIBIBYTE |
| 132 | LANG_GIBIBYTE |
| 133 | LANG_USB_HID |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 134 | VOICE_ZERO |
| 135 | VOICE_ONE |
| 136 | VOICE_TWO |
| 137 | VOICE_THREE |
| 138 | VOICE_FOUR |
| 139 | VOICE_FIVE |
| 140 | VOICE_SIX |
| 141 | VOICE_SEVEN |
| 142 | VOICE_EIGHT |
| 143 | VOICE_NINE |
| 144 | VOICE_TEN |
| 145 | VOICE_ELEVEN |
| 146 | VOICE_TWELVE |
| 147 | VOICE_THIRTEEN |
| 148 | VOICE_FOURTEEN |
| 149 | VOICE_FIFTEEN |
| 150 | VOICE_SIXTEEN |
| 151 | VOICE_SEVENTEEN |
| 152 | VOICE_EIGHTEEN |
| 153 | VOICE_NINETEEN |
| 154 | VOICE_TWENTY |
| 155 | VOICE_THIRTY |
| 156 | VOICE_FORTY |
| 157 | VOICE_FIFTY |
| 158 | VOICE_SIXTY |
| 159 | VOICE_SEVENTY |
| 160 | VOICE_EIGHTY |
| 161 | VOICE_NINETY |
| 162 | VOICE_CHAR_A |
| 163 | VOICE_CHAR_B |
| 164 | VOICE_CHAR_C |
| 165 | VOICE_CHAR_D |
| 166 | VOICE_CHAR_E |
| 167 | VOICE_CHAR_F |
| 168 | VOICE_CHAR_G |
| 169 | VOICE_CHAR_H |
| 170 | VOICE_CHAR_I |
| 171 | VOICE_CHAR_J |
| 172 | VOICE_CHAR_K |
| 173 | VOICE_CHAR_L |
| 174 | VOICE_CHAR_M |
| 175 | VOICE_CHAR_N |
| 176 | VOICE_CHAR_O |
| 177 | VOICE_CHAR_P |
| 178 | VOICE_CHAR_Q |
| 179 | VOICE_CHAR_R |
| 180 | VOICE_CHAR_S |
| 181 | VOICE_CHAR_T |
| 182 | VOICE_CHAR_U |
| 183 | VOICE_CHAR_V |
| 184 | VOICE_CHAR_W |
| 185 | VOICE_CHAR_X |
| 186 | VOICE_CHAR_Y |
| 187 | VOICE_CHAR_Z |
| 188 | VOICE_PAUSE"); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 189 | foreach($phrases as $id => $phrase) { |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 190 | if (in_array($id, $ignoreidentical)) { |
| 191 | continue; |
| 192 | } |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 193 | foreach($phrase['source'] as $target => $value) { |
| 194 | if ($phrase['source'][$target] == $phrase['dest'][$target] |
| 195 | && $phrase['source'][$target] != 'none' |
| 196 | && $phrase['source'][$target] != '' |
| 197 | ) { |
| 198 | $strings[] = sprintf("<strong>%s:%s</strong>: English and translation are the same (\"%s\")<br />\n", |
| 199 | $id, |
| 200 | $target, |
| 201 | $value |
| 202 | ); |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | if (sizeof($strings) > 0) { |
| 207 | print("<h2>Identical English and translation</h2>"); |
| 208 | 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] | 209 | print(join($strings, '')); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | |
| 213 | $strings = array(); |
| 214 | foreach($english as $id => $phrase) { |
| 215 | foreach($phrase['source'] as $target => $value) { |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 216 | if (($phrases[$id]['voice'][$target] == '' |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 217 | || $phrases[$id]['voice'][$target] == 'none') |
| 218 | && $phrase['voice'][$target] != '' |
| 219 | && $phrase['voice'][$target] != 'none' |
| 220 | ) { |
| 221 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice missing (english voice: \"%s\")<br />\n", |
| 222 | $id, |
| 223 | $target, |
| 224 | $phrase['voice'][$target] |
| 225 | ); |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | if (sizeof($strings) > 0) { |
| 230 | print("<h2>Missing voice strings</h2>"); |
| 231 | 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] | 232 | print(join($strings, '')); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | $strings = array(); |
| 236 | foreach($phrases as $id => $phrase) { |
Jonas Häggqvist | 712948b | 2010-10-23 16:00:31 +0000 | [diff] [blame] | 237 | if (in_array($id, $ignoreidentical)) { |
| 238 | continue; |
| 239 | } |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 240 | foreach($phrase['source'] as $target => $value) { |
| 241 | if ($phrase['voice'][$target] == $value && $value != '' && $value != 'none') { |
| 242 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice and source are the same (\"%s\")<br />\n", |
| 243 | $id, |
| 244 | $target, |
| 245 | $value |
| 246 | ); |
| 247 | } |
| 248 | elseif ($english[$id]['voice'][$target] == $phrase['voice'][$target] |
| 249 | && $english[$id]['voice'][$target] != 'none' |
| 250 | && $english[$id]['voice'][$target] != '' |
| 251 | ) { |
| 252 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice and English voice are the same (\"%s\")<br />\n", |
| 253 | $id, |
| 254 | $target, |
| 255 | $english[$id]['voice'][$target] |
| 256 | ); |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | if (sizeof($strings) > 0) { |
| 261 | print("<h2>Same voice and source</h2>"); |
| 262 | 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] | 263 | print(join($strings, '')); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 264 | } |
| 265 | |
Frank Gevaerts | f6a9d68 | 2012-04-04 21:26:38 +0200 | [diff] [blame] | 266 | print("<!--\n"); |
| 267 | print_r($english); |
| 268 | print("\n-->\n"); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 269 | |
| 270 | $strings = array(); |
| 271 | foreach($phrases as $id => $phrase) { |
| 272 | foreach($phrase['voice'] as $target => $value) { |
| 273 | if (!isset($english[$id]['voice'][$target]) |
| 274 | && $value != "" |
| 275 | && $value != "none" |
| 276 | ) { |
| 277 | $strings[] = sprintf("<strong>%s:%s</strong>: Voice not defined for English (set to: \"%s\")<br />\n", |
| 278 | $id, |
| 279 | $target, |
| 280 | $value |
| 281 | ); |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | if (sizeof($strings) > 0) { |
| 286 | print("<h2>Unnecessary voice strings</h2>"); |
| 287 | print("<p>These strings are unnecessary, since they're not defined in the English language file. They should probably be removed</p>\n"); |
| 288 | print(join($strings, '')); |
| 289 | } |
| 290 | |
| 291 | if (true || $_SERVER['REMOTE_ADDR'] == trim(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/homeip'))) { |
| 292 | echo <<<MOO |
| 293 | <h2>Check your work in progress</h2> |
| 294 | <p>Using the form below, you can upload a work in progress and generate a report |
| 295 | similar to this one, for your language.</p> |
| 296 | <form enctype="multipart/form-data" action="problems.php" method="post"> |
| 297 | <input type="hidden" name="upload" value="true" /> |
| 298 | <input type="file" name="langfile" /> |
| 299 | <input type="submit" value="send" /> |
| 300 | </form> |
| 301 | MOO; |
| 302 | } |
| 303 | |
| 304 | print_foot(); |
| 305 | ?> |