blob: 8e23c911118e738fd39c412081a22e29c1a6a11f [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();
Solomon Peachy57436542020-07-28 15:24:00 -0400116
117$ignoreidentical = explode("\n", file_get_contents("rockbox/tools/langignorelist.txt"));
118
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000119foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000120 if (in_array($id, $ignoreidentical)) {
121 continue;
122 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000123 foreach($phrase['source'] as $target => $value) {
124 if ($phrase['source'][$target] == $phrase['dest'][$target]
125 && $phrase['source'][$target] != 'none'
126 && $phrase['source'][$target] != ''
127 ) {
128 $strings[] = sprintf("<strong>%s:%s</strong>: English and translation are the same (\"%s\")<br />\n",
129 $id,
130 $target,
131 $value
132 );
133 }
134 }
135}
136if (sizeof($strings) > 0) {
137 print("<h2>Identical English and translation</h2>");
138 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 -0400139 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000140}
141
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000142$strings = array();
143foreach($english as $id => $phrase) {
144 foreach($phrase['source'] as $target => $value) {
Solomon Peachyb6aacc12020-07-27 17:32:10 -0400145 if (isset($phrases[$id]) &&
146 ($phrases[$id]['voice'][$target] == ''
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000147 || $phrases[$id]['voice'][$target] == 'none')
148 && $phrase['voice'][$target] != ''
149 && $phrase['voice'][$target] != 'none'
150 ) {
151 $strings[] = sprintf("<strong>%s:%s</strong>: Voice missing (english voice: \"%s\")<br />\n",
152 $id,
153 $target,
154 $phrase['voice'][$target]
155 );
156 }
157 }
158}
159if (sizeof($strings) > 0) {
160 print("<h2>Missing voice strings</h2>");
161 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 -0400162 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000163}
164
165$strings = array();
166foreach($phrases as $id => $phrase) {
Jonas Häggqvist712948b2010-10-23 16:00:31 +0000167 if (in_array($id, $ignoreidentical)) {
168 continue;
169 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000170 foreach($phrase['source'] as $target => $value) {
171 if ($phrase['voice'][$target] == $value && $value != '' && $value != 'none') {
172 $strings[] = sprintf("<strong>%s:%s</strong>: Voice and source are the same (\"%s\")<br />\n",
173 $id,
174 $target,
175 $value
176 );
177 }
178 elseif ($english[$id]['voice'][$target] == $phrase['voice'][$target]
179 && $english[$id]['voice'][$target] != 'none'
180 && $english[$id]['voice'][$target] != ''
181 ) {
182 $strings[] = sprintf("<strong>%s:%s</strong>: Voice and English voice are the same (\"%s\")<br />\n",
183 $id,
184 $target,
185 $english[$id]['voice'][$target]
186 );
187 }
188 }
189}
190if (sizeof($strings) > 0) {
191 print("<h2>Same voice and source</h2>");
192 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 -0400193 print(join($strings, ''));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000194}
195
Frank Gevaertsf6a9d682012-04-04 21:26:38 +0200196print("<!--\n");
197print_r($english);
198print("\n-->\n");
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000199
200$strings = array();
201foreach($phrases as $id => $phrase) {
202 foreach($phrase['voice'] as $target => $value) {
203 if (!isset($english[$id]['voice'][$target])
204 && $value != ""
205 && $value != "none"
206 ) {
207 $strings[] = sprintf("<strong>%s:%s</strong>: Voice not defined for English (set to: \"%s\")<br />\n",
208 $id,
209 $target,
210 $value
211 );
212 }
213 }
214}
215if (sizeof($strings) > 0) {
216 print("<h2>Unnecessary voice strings</h2>");
217 print("<p>These strings are unnecessary, since they're not defined in the English language file. They should probably be removed</p>\n");
218 print(join($strings, ''));
219}
220
221if (true || $_SERVER['REMOTE_ADDR'] == trim(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/homeip'))) {
222 echo <<<MOO
223 <h2>Check your work in progress</h2>
224 <p>Using the form below, you can upload a work in progress and generate a report
225 similar to this one, for your language.</p>
226 <form enctype="multipart/form-data" action="problems.php" method="post">
227 <input type="hidden" name="upload" value="true" />
228 <input type="file" name="langfile" />
229 <input type="submit" value="send" />
230 </form>
231MOO;
232}
233
234print_foot();
235?>