blob: ebde1896aa9669de91b31ac55c79a1aa4383d96b [file] [log] [blame]
Jonas Häggqvistb632ed12010-01-30 02:04:47 +00001<?php
2require_once('common.php');
3print_head();
4
5if (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}
10else {
11 $lang = isset($_GET['lang']) ? $_GET['lang'] : '';
Jonas Häggqvist492a7b62011-06-05 10:57:52 +000012 $phrases = parselangfile(sprintf('rockbox/apps/lang/%s.lang', $lang));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000013}
14
15if ($phrases === false) die("This language doesn't exist, you bad man!");
Frank Gevaertsf6a9d682012-04-04 21:26:38 +020016$english = parselangfile('rockbox/apps/lang/english.lang');
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000017
18if ($lang == 'english') {
19echo <<<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>
24MOO;
25 print_foot();
26 die();
27}
28echo <<<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
33don't offer a way to fix this automatically, so you'll have to edit the language
34file by hand. Hopefully this page will still be of some help. Note that not all
35of these lines have to be actual problems, so pay attention to what you do.</p>
36MOO;
37
38$strings = array();
39foreach($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}
63if (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();
70foreach($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}
88if (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äggqvist712948b2010-10-23 16:00:31 +000095$ignoreidentical = explode("\n",
96"LANG_SERIAL_BITRATE_19200
97LANG_SERIAL_BITRATE_9600
98LANG_SERIAL_BITRATE_38400
99LANG_SERIAL_BITRATE_57600
100LANG_COMPRESSOR_RATIO_10
101LANG_COMPRESSOR_RATIO_2
102LANG_COMPRESSOR_RATIO_6
103LANG_COMPRESSOR_RATIO_4
104LANG_ROCKBOX_TITLE
105LANG_EQUALIZER_BAND_Q
106LANG_COLOR_RGB_LABELS
107LANG_BYTE
108VOICE_ZERO
109VOICE_ONE
110VOICE_TWO
111VOICE_THREE
112VOICE_FOUR
113VOICE_FIVE
114VOICE_SIX
115VOICE_SEVEN
116VOICE_EIGHT
117VOICE_NINE
118VOICE_TEN
119VOICE_ELEVEN
120VOICE_TWELVE
121VOICE_THIRTEEN
122VOICE_FOURTEEN
123VOICE_FIFTEEN
124VOICE_SIXTEEN
125VOICE_SEVENTEEN
126VOICE_EIGHTEEN
127VOICE_NINETEEN
128VOICE_TWENTY
129VOICE_THIRTY
130VOICE_FORTY
131VOICE_FIFTY
132VOICE_SIXTY
133VOICE_SEVENTY
134VOICE_EIGHTY
135VOICE_NINETY
136VOICE_CHAR_A
137VOICE_CHAR_B
138VOICE_CHAR_C
139VOICE_CHAR_D
140VOICE_CHAR_E
141VOICE_CHAR_F
142VOICE_CHAR_G
143VOICE_CHAR_H
144VOICE_CHAR_I
145VOICE_CHAR_J
146VOICE_CHAR_K
147VOICE_CHAR_L
148VOICE_CHAR_M
149VOICE_CHAR_N
150VOICE_CHAR_O
151VOICE_CHAR_P
152VOICE_CHAR_Q
153VOICE_CHAR_R
154VOICE_CHAR_S
155VOICE_CHAR_T
156VOICE_CHAR_U
157VOICE_CHAR_V
158VOICE_CHAR_W
159VOICE_CHAR_X
160VOICE_CHAR_Y
161VOICE_CHAR_Z
162VOICE_PAUSE");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000163foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000164 if (in_array($id, $ignoreidentical)) {
165 continue;
166 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000167 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}
180if (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();
188foreach($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}
203if (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();
210foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000211 if (in_array($id, $ignoreidentical)) {
212 continue;
213 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000214 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}
234if (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 Gevaertsf6a9d682012-04-04 21:26:38 +0200240print("<!--\n");
241print_r($english);
242print("\n-->\n");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000243
244$strings = array();
245foreach($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}
259if (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
265if (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>
275MOO;
276}
277
278print_foot();
279?>