blob: 79726bb9558ef683932a39a3a2a3ccd9fa581bdf [file] [log] [blame]
Jonas Häggqvistb632ed12010-01-30 02:04:47 +00001<?php
Solomon Peachya0eef362020-04-02 10:05:23 -04002/************************************************************************
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äggqvistb632ed12010-01-30 02:04:47 +000021require_once('common.php');
22print_head();
23
Frank Gevaerts065257f2013-02-16 13:36:05 +010024$languageinfo = languageinfo();
25
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000026if (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}
31else {
32 $lang = isset($_GET['lang']) ? $_GET['lang'] : '';
Jonas Häggqvist492a7b62011-06-05 10:57:52 +000033 $phrases = parselangfile(sprintf('rockbox/apps/lang/%s.lang', $lang));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000034}
35
36if ($phrases === false) die("This language doesn't exist, you bad man!");
Frank Gevaertsf6a9d682012-04-04 21:26:38 +020037$english = parselangfile('rockbox/apps/lang/english.lang');
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000038
39if ($lang == 'english') {
40echo <<<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>
45MOO;
46 print_foot();
47 die();
48}
49echo <<<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
54don't offer a way to fix this automatically, so you'll have to edit the language
55file by hand. Hopefully this page will still be of some help. Note that not all
56of these lines have to be actual problems, so pay attention to what you do.</p>
57MOO;
58
59$strings = array();
60foreach($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}
84if (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 Peachya0eef362020-04-02 10:05:23 -040087 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000088}
89
90$strings = array();
91foreach($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 Peachy7cb0b9e2020-07-26 11:18:44 -040098 $strings[] = sprintf("<strong>%s:%s - %s</strong>: Empty string doesn't match English (set to: '%s' - should be: '%s')<br />\n",
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000099 $id,
100 $target,
101 $what,
102 $value == '' ? '""' : $value,
103 $english[$id][$what][$target]
104 );
105 }
106 }
107 }
108}
109if (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äggqvist712948b2010-10-23 16:00:31 +0000116$ignoreidentical = explode("\n",
117"LANG_SERIAL_BITRATE_19200
118LANG_SERIAL_BITRATE_9600
119LANG_SERIAL_BITRATE_38400
120LANG_SERIAL_BITRATE_57600
121LANG_COMPRESSOR_RATIO_10
122LANG_COMPRESSOR_RATIO_2
123LANG_COMPRESSOR_RATIO_6
124LANG_COMPRESSOR_RATIO_4
125LANG_ROCKBOX_TITLE
126LANG_EQUALIZER_BAND_Q
Solomon Peachy38ee3ba2020-07-27 13:17:49 -0400127LANG_FM_DEFAULT_PRESET_NAME
128LANG_DISK_NAME_MMC
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000129LANG_COLOR_RGB_LABELS
130LANG_BYTE
Solomon Peachy38ee3ba2020-07-27 13:17:49 -0400131LANG_KIBIBYTE
132LANG_GIBIBYTE
133LANG_USB_HID
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000134VOICE_ZERO
135VOICE_ONE
136VOICE_TWO
137VOICE_THREE
138VOICE_FOUR
139VOICE_FIVE
140VOICE_SIX
141VOICE_SEVEN
142VOICE_EIGHT
143VOICE_NINE
144VOICE_TEN
145VOICE_ELEVEN
146VOICE_TWELVE
147VOICE_THIRTEEN
148VOICE_FOURTEEN
149VOICE_FIFTEEN
150VOICE_SIXTEEN
151VOICE_SEVENTEEN
152VOICE_EIGHTEEN
153VOICE_NINETEEN
154VOICE_TWENTY
155VOICE_THIRTY
156VOICE_FORTY
157VOICE_FIFTY
158VOICE_SIXTY
159VOICE_SEVENTY
160VOICE_EIGHTY
161VOICE_NINETY
162VOICE_CHAR_A
163VOICE_CHAR_B
164VOICE_CHAR_C
165VOICE_CHAR_D
166VOICE_CHAR_E
167VOICE_CHAR_F
168VOICE_CHAR_G
169VOICE_CHAR_H
170VOICE_CHAR_I
171VOICE_CHAR_J
172VOICE_CHAR_K
173VOICE_CHAR_L
174VOICE_CHAR_M
175VOICE_CHAR_N
176VOICE_CHAR_O
177VOICE_CHAR_P
178VOICE_CHAR_Q
179VOICE_CHAR_R
180VOICE_CHAR_S
181VOICE_CHAR_T
182VOICE_CHAR_U
183VOICE_CHAR_V
184VOICE_CHAR_W
185VOICE_CHAR_X
186VOICE_CHAR_Y
187VOICE_CHAR_Z
188VOICE_PAUSE");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000189foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000190 if (in_array($id, $ignoreidentical)) {
191 continue;
192 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000193 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}
206if (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 Peachya0eef362020-04-02 10:05:23 -0400209 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000210}
211
212
213$strings = array();
214foreach($english as $id => $phrase) {
215 foreach($phrase['source'] as $target => $value) {
Solomon Peachya0eef362020-04-02 10:05:23 -0400216 if (($phrases[$id]['voice'][$target] == ''
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000217 || $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}
229if (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 Peachya0eef362020-04-02 10:05:23 -0400232 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000233}
234
235$strings = array();
236foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000237 if (in_array($id, $ignoreidentical)) {
238 continue;
239 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000240 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}
260if (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 Peachya0eef362020-04-02 10:05:23 -0400263 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000264}
265
Frank Gevaertsf6a9d682012-04-04 21:26:38 +0200266print("<!--\n");
267print_r($english);
268print("\n-->\n");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000269
270$strings = array();
271foreach($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}
285if (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
291if (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>
301MOO;
302}
303
304print_foot();
305?>