blob: dec884f91195bc6eb67a6454f8346449d21b5803 [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 ) {
98 $strings[] = sprintf("<strong>%s:%s - %s</strong>: Empty string doesn't match English (set to: %s - should be: %s)<br />\n",
99 $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
127LANG_COLOR_RGB_LABELS
128LANG_BYTE
129VOICE_ZERO
130VOICE_ONE
131VOICE_TWO
132VOICE_THREE
133VOICE_FOUR
134VOICE_FIVE
135VOICE_SIX
136VOICE_SEVEN
137VOICE_EIGHT
138VOICE_NINE
139VOICE_TEN
140VOICE_ELEVEN
141VOICE_TWELVE
142VOICE_THIRTEEN
143VOICE_FOURTEEN
144VOICE_FIFTEEN
145VOICE_SIXTEEN
146VOICE_SEVENTEEN
147VOICE_EIGHTEEN
148VOICE_NINETEEN
149VOICE_TWENTY
150VOICE_THIRTY
151VOICE_FORTY
152VOICE_FIFTY
153VOICE_SIXTY
154VOICE_SEVENTY
155VOICE_EIGHTY
156VOICE_NINETY
157VOICE_CHAR_A
158VOICE_CHAR_B
159VOICE_CHAR_C
160VOICE_CHAR_D
161VOICE_CHAR_E
162VOICE_CHAR_F
163VOICE_CHAR_G
164VOICE_CHAR_H
165VOICE_CHAR_I
166VOICE_CHAR_J
167VOICE_CHAR_K
168VOICE_CHAR_L
169VOICE_CHAR_M
170VOICE_CHAR_N
171VOICE_CHAR_O
172VOICE_CHAR_P
173VOICE_CHAR_Q
174VOICE_CHAR_R
175VOICE_CHAR_S
176VOICE_CHAR_T
177VOICE_CHAR_U
178VOICE_CHAR_V
179VOICE_CHAR_W
180VOICE_CHAR_X
181VOICE_CHAR_Y
182VOICE_CHAR_Z
183VOICE_PAUSE");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000184foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000185 if (in_array($id, $ignoreidentical)) {
186 continue;
187 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000188 foreach($phrase['source'] as $target => $value) {
189 if ($phrase['source'][$target] == $phrase['dest'][$target]
190 && $phrase['source'][$target] != 'none'
191 && $phrase['source'][$target] != ''
192 ) {
193 $strings[] = sprintf("<strong>%s:%s</strong>: English and translation are the same (\"%s\")<br />\n",
194 $id,
195 $target,
196 $value
197 );
198 }
199 }
200}
201if (sizeof($strings) > 0) {
202 print("<h2>Identical English and translation</h2>");
203 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 -0400204 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000205}
206
207
208$strings = array();
209foreach($english as $id => $phrase) {
210 foreach($phrase['source'] as $target => $value) {
Solomon Peachya0eef362020-04-02 10:05:23 -0400211 if (($phrases[$id]['voice'][$target] == ''
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000212 || $phrases[$id]['voice'][$target] == 'none')
213 && $phrase['voice'][$target] != ''
214 && $phrase['voice'][$target] != 'none'
215 ) {
216 $strings[] = sprintf("<strong>%s:%s</strong>: Voice missing (english voice: \"%s\")<br />\n",
217 $id,
218 $target,
219 $phrase['voice'][$target]
220 );
221 }
222 }
223}
224if (sizeof($strings) > 0) {
225 print("<h2>Missing voice strings</h2>");
226 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 -0400227 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000228}
229
230$strings = array();
231foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000232 if (in_array($id, $ignoreidentical)) {
233 continue;
234 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000235 foreach($phrase['source'] as $target => $value) {
236 if ($phrase['voice'][$target] == $value && $value != '' && $value != 'none') {
237 $strings[] = sprintf("<strong>%s:%s</strong>: Voice and source are the same (\"%s\")<br />\n",
238 $id,
239 $target,
240 $value
241 );
242 }
243 elseif ($english[$id]['voice'][$target] == $phrase['voice'][$target]
244 && $english[$id]['voice'][$target] != 'none'
245 && $english[$id]['voice'][$target] != ''
246 ) {
247 $strings[] = sprintf("<strong>%s:%s</strong>: Voice and English voice are the same (\"%s\")<br />\n",
248 $id,
249 $target,
250 $english[$id]['voice'][$target]
251 );
252 }
253 }
254}
255if (sizeof($strings) > 0) {
256 print("<h2>Same voice and source</h2>");
257 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 -0400258 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000259}
260
Frank Gevaertsf6a9d682012-04-04 21:26:38 +0200261print("<!--\n");
262print_r($english);
263print("\n-->\n");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000264
265$strings = array();
266foreach($phrases as $id => $phrase) {
267 foreach($phrase['voice'] as $target => $value) {
268 if (!isset($english[$id]['voice'][$target])
269 && $value != ""
270 && $value != "none"
271 ) {
272 $strings[] = sprintf("<strong>%s:%s</strong>: Voice not defined for English (set to: \"%s\")<br />\n",
273 $id,
274 $target,
275 $value
276 );
277 }
278 }
279}
280if (sizeof($strings) > 0) {
281 print("<h2>Unnecessary voice strings</h2>");
282 print("<p>These strings are unnecessary, since they're not defined in the English language file. They should probably be removed</p>\n");
283 print(join($strings, ''));
284}
285
286if (true || $_SERVER['REMOTE_ADDR'] == trim(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/homeip'))) {
287 echo <<<MOO
288 <h2>Check your work in progress</h2>
289 <p>Using the form below, you can upload a work in progress and generate a report
290 similar to this one, for your language.</p>
291 <form enctype="multipart/form-data" action="problems.php" method="post">
292 <input type="hidden" name="upload" value="true" />
293 <input type="file" name="langfile" />
294 <input type="submit" value="send" />
295 </form>
296MOO;
297}
298
299print_foot();
300?>