blob: 9f13e3e6a61c6c7bfce07508d445f77095f54941 [file] [log] [blame]
Jonas Häggqvistb632ed12010-01-30 02:04:47 +00001<?php
2require_once('common.php');
3print_head();
4
Frank Gevaerts065257f2013-02-16 13:36:05 +01005$languageinfo = languageinfo();
6
Jonas Häggqvistb632ed12010-01-30 02:04:47 +00007if (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}
12else {
13 $lang = isset($_GET['lang']) ? $_GET['lang'] : '';
Jonas Häggqvist492a7b62011-06-05 10:57:52 +000014 $phrases = parselangfile(sprintf('rockbox/apps/lang/%s.lang', $lang));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000015}
16
17if ($phrases === false) die("This language doesn't exist, you bad man!");
Frank Gevaertsf6a9d682012-04-04 21:26:38 +020018$english = parselangfile('rockbox/apps/lang/english.lang');
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000019
20if ($lang == 'english') {
21echo <<<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>
26MOO;
27 print_foot();
28 die();
29}
30echo <<<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
35don't offer a way to fix this automatically, so you'll have to edit the language
36file by hand. Hopefully this page will still be of some help. Note that not all
37of these lines have to be actual problems, so pay attention to what you do.</p>
38MOO;
39
40$strings = array();
41foreach($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}
65if (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();
72foreach($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}
90if (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äggqvist712948b2010-10-23 16:00:31 +000097$ignoreidentical = explode("\n",
98"LANG_SERIAL_BITRATE_19200
99LANG_SERIAL_BITRATE_9600
100LANG_SERIAL_BITRATE_38400
101LANG_SERIAL_BITRATE_57600
102LANG_COMPRESSOR_RATIO_10
103LANG_COMPRESSOR_RATIO_2
104LANG_COMPRESSOR_RATIO_6
105LANG_COMPRESSOR_RATIO_4
106LANG_ROCKBOX_TITLE
107LANG_EQUALIZER_BAND_Q
108LANG_COLOR_RGB_LABELS
109LANG_BYTE
110VOICE_ZERO
111VOICE_ONE
112VOICE_TWO
113VOICE_THREE
114VOICE_FOUR
115VOICE_FIVE
116VOICE_SIX
117VOICE_SEVEN
118VOICE_EIGHT
119VOICE_NINE
120VOICE_TEN
121VOICE_ELEVEN
122VOICE_TWELVE
123VOICE_THIRTEEN
124VOICE_FOURTEEN
125VOICE_FIFTEEN
126VOICE_SIXTEEN
127VOICE_SEVENTEEN
128VOICE_EIGHTEEN
129VOICE_NINETEEN
130VOICE_TWENTY
131VOICE_THIRTY
132VOICE_FORTY
133VOICE_FIFTY
134VOICE_SIXTY
135VOICE_SEVENTY
136VOICE_EIGHTY
137VOICE_NINETY
138VOICE_CHAR_A
139VOICE_CHAR_B
140VOICE_CHAR_C
141VOICE_CHAR_D
142VOICE_CHAR_E
143VOICE_CHAR_F
144VOICE_CHAR_G
145VOICE_CHAR_H
146VOICE_CHAR_I
147VOICE_CHAR_J
148VOICE_CHAR_K
149VOICE_CHAR_L
150VOICE_CHAR_M
151VOICE_CHAR_N
152VOICE_CHAR_O
153VOICE_CHAR_P
154VOICE_CHAR_Q
155VOICE_CHAR_R
156VOICE_CHAR_S
157VOICE_CHAR_T
158VOICE_CHAR_U
159VOICE_CHAR_V
160VOICE_CHAR_W
161VOICE_CHAR_X
162VOICE_CHAR_Y
163VOICE_CHAR_Z
164VOICE_PAUSE");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000165foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000166 if (in_array($id, $ignoreidentical)) {
167 continue;
168 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000169 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}
182if (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();
190foreach($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}
205if (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();
212foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000213 if (in_array($id, $ignoreidentical)) {
214 continue;
215 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000216 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}
236if (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 Gevaertsf6a9d682012-04-04 21:26:38 +0200242print("<!--\n");
243print_r($english);
244print("\n-->\n");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000245
246$strings = array();
247foreach($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}
261if (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
267if (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>
277MOO;
278}
279
280print_foot();
281?>