blob: 9c3169f5302dfd11287df2729d35f9afaac117a3 [file] [log] [blame]
Jonas Häggqvistb632ed12010-01-30 02:04:47 +00001<?php
2error_reporting(E_ALL);
3require_once('common.php');
4
5function edit($lang) {
6 $languageinfo = languageinfo();
7 $LARGE_FLAGSIZE = LARGE_FLAGSIZE;
8 echo <<<END
9<img class="flag" src="flags/{$LARGE_FLAGSIZE}/{$languageinfo[$lang]['flag']}.png" />
10<h1>Edit {$languageinfo[$lang]['name']} language</h1>
11<p>Go <a href="index.php">back</a>.</p>
12<p>
13Go through this list and follow the instructions given <span class="note">marked in dark red</span>. When
14you're done, press the "Finish translating" button at the bottom of this page.<!-- ' -->
15You will then be sent a patch file with your changes. Submit this file
16to Rockbox on the <a href="http://www.rockbox.org/tracker/newtask/proj1">patch
17tracker</a>.
18</p>
19<p>
20If a field is read-only, it means that this string is not meant to be translated
21and you should leave it as-is. The special string "none" is not meant to be
22translated, so if you see it in the english version, put "none" in the
23translation as well.
24</p>
25<form action="submit.php" method="post">
26<input type="hidden" name="lang" value="$lang" />
27END;
28
Jonas Häggqvist04e454b2010-01-31 01:50:52 +000029 $phrases = parselangfile(sprintf("rockbox/apps/lang/%s.lang.update", $lang));
30 $english = parselangfile(sprintf("rockbox/apps/lang/%s.lang.update", 'english'));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000031 if ($phrases === false || $english === false) {
32 printf("<strong>The file %s.lang doesn't exist, or something else went terribly wrong</strong>", $lang);
33 return false;
34 }
35
36 $inputlang = isset($languageinfo[$lang]['code']) && $languageinfo[$lang]['code'] != '' ? sprintf(" lang='%s' ", $languageinfo[$lang]['code']) : '';
37 $inputdir = isset($languageinfo[$lang]['rtl']) && $languageinfo[$lang]['rtl'] === true ? " dir='rtl' " : '';
38 foreach($phrases as $id => $phrase) {
39 if (sizeof($phrase['notes']) > 0 && trim(strtolower($phrase['phrase']['desc'])) != "deprecated") {
40 printf("<h3>%s</h3>", $phrase['phrase']['id']);
41
42 if (isset($phrase['phrase']['desc']))
43 printf("Description: %s<br />\n", $phrase['phrase']['desc']);
44 if (isset($phrase['phrase']['user']) && $phrase['phrase']['user'] != '')
45 printf("User: %s<br />\n", $phrase['phrase']['user']);
46
47 if (sizeof($phrase['notes']) > 0) {
48 print("<div class='note'>");
49 foreach($phrase['notes'] as $line) {
50 printf("%s<br />\n", htmlspecialchars($line));
51 }
52 print("</div>");
53 }
54
55 printf("<table><thead><tr><td>Target/feature</td><td>English string</td><td>%s translation</td><td>English voice</td><td>%s voice</td></tr></thead>", $languageinfo[$lang]['name'], $languageinfo[$lang]['name']);
56 foreach($phrase['source'] as $target => $string) {
57 // Figure out what to put in the translated string
58 if (isset($english[$id]['dest'][$target]) && ($english[$id]['dest'][$target] == '' || $english[$id]['dest'][$target] == 'none')) {
59 $translated_value = $phrase['dest'][$target] = $english[$id]['dest'][$target];
60 }
61 elseif (isset($phrase['dest'][$target]) && $phrase['dest'][$target] != '' && $phrase['dest'][$target] != 'none') {
62 $translated_value = $phrase['dest'][$target];
63 }
64 else {
65 $translated_value = '';
66 }
67
68 // Figure out whether to set the translated value readonly
69 if (
70 // If english string is either unset, '' or none
71 (!isset($english[$id]['source'][$target]) || $english[$id]['source'][$target] == '' || $english[$id]['source'][$target] == 'none')
72 &&
73 // And destination is either unset or set to '' or none
74 (!isset($phrase['dest'][$target]) || ($phrase['dest'][$target] == '' || $phrase['dest'][$target] == 'none'))
75 ) {
76 $translated_readonly = 'readonly="readonly" class="readonly"';
77 }
78 else {
79 $translated_readonly = '';
80 }
81
82 // Figure out what to put in the voice string
83 if (isset($english[$id]['voice'][$target]) && ($english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')) {
84 $voice_value = $phrase['voice'][$target] = $english[$id]['voice'][$target];
85 }
86 elseif (isset($phrase['voice'][$target]) && $phrase['voice'][$target] != '' && $phrase['voice'][$target] != 'none') {
87 $voice_value = $phrase['voice'][$target];
88 }
89 else {
90 $voice_value = '';
91 }
92
93 // Figure out whether to set the voice value readonly
94 if (
95 // If english voice is either unset, '' or none
96 (!isset($english[$id]['voice'][$target]) || $english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')
97 &&
98 // And voice is not set, or set to '' or none
99 (!isset($phrase['voice'][$target]) || ($phrase['voice'][$target] == '' || $phrase['voice'][$target] == 'none'))
100 ) {
101 $voice_readonly = 'readonly="readonly" class="readonly"';
102 }
103 else {
104 $voice_readonly = '';
105 }
106
107 print("<tr>");
108 printf("<td>%s</td><td>%s</td><td><input %s %s name='phrases[%s][dest][%s]' size='40' type='text' value='%s' %s /></td>",
109 htmlspecialchars($target),
110 htmlspecialchars($string),
111 $inputlang,
112 $inputdir,
113 htmlspecialchars($id),
114 htmlspecialchars($target),
115 htmlspecialchars($translated_value, ENT_QUOTES),
116 $translated_readonly
117 );
118
119 if (!isset($english[$id]['voice'][$target])) {
120 print("<td colspan='2'></td>");
121 }
122 else {
123 printf("<td>%s</td><td><input %s %s name='phrases[%s][voice][%s]' size='40' type='text' value='%s' %s /></td>",
124 htmlspecialchars(isset($english[$id]['voice'][$target]) ? $english[$id]['voice'][$target] : ''),
125 $inputlang,
126 $inputdir,
127 htmlspecialchars($id),
128 htmlspecialchars($target),
129 htmlspecialchars($voice_value, ENT_QUOTES),
130 $voice_readonly
131 );
132 }
133 print("</tr>\n");
134 }
135 print("</table>");
136 }
137 elseif (trim(strtolower($phrase['phrase']['desc'])) == "deprecated") {
138 printf("<input type='hidden' name='phrases[%s][dest][*]' value='' /><input type='hidden' name='phrases[%s][dest][*]' value='' />",
139 htmlspecialchars($id),
140 htmlspecialchars($id)
141 );
142 }
143 }
144echo <<<END
145<input type="submit" value="Finish translating" style="margin-top: 1em" />
146</form>
147<p>
148When you click this button, you will be sent a Rockbox language file. If you are
149satisfied with your changes, you're<!-- ' --> encouraged to submit this file in
150the <a href="http://www.rockbox.org/tracker/newtask/proj1">Rockbox patch
151tracker.</a>
152</p>
153END;
154}
155
156print_head();
157edit($_REQUEST['lang']);
158print_foot();
159?>