blob: 22c03d7fce52393a34314a6eda35a9aca7c2fcf0 [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
21error_reporting(E_ALL);
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000022require_once('common.php');
23
24function edit($lang) {
25 $languageinfo = languageinfo();
26 $LARGE_FLAGSIZE = LARGE_FLAGSIZE;
27 echo <<<END
28<img class="flag" src="flags/{$LARGE_FLAGSIZE}/{$languageinfo[$lang]['flag']}.png" />
29<h1>Edit {$languageinfo[$lang]['name']} language</h1>
30<p>Go <a href="index.php">back</a>.</p>
31<p>
32Go through this list and follow the instructions given <span class="note">marked in dark red</span>. When
33you're done, press the "Finish translating" button at the bottom of this page.<!-- ' -->
34You will then be sent a patch file with your changes. Submit this file
Solomon Peachy5a27db82020-04-22 23:15:19 -040035to Rockbox on the <a href="//www.rockbox.org/tracker/newtask/proj1">patch
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000036tracker</a>.
37</p>
Solomon Peachyededdf62020-05-21 21:24:55 -040038<p><b>Please note we will need your full legal name in order to accept any patches, including translation updates!</b></p>
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000039<p>
40If a field is read-only, it means that this string is not meant to be translated
41and you should leave it as-is. The special string "none" is not meant to be
42translated, so if you see it in the english version, put "none" in the
43translation as well.
44</p>
45<form action="submit.php" method="post">
46<input type="hidden" name="lang" value="$lang" />
47END;
48
Solomon Peachyb61343c2020-07-27 15:59:47 -040049 $phrases = parselangfile(sprintf("scratch/%s.lang.update", $lang));
50 $english = parselangfile(sprintf("scratch/%s.lang.update", 'english'));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000051 if ($phrases === false || $english === false) {
52 printf("<strong>The file %s.lang doesn't exist, or something else went terribly wrong</strong>", $lang);
53 return false;
54 }
55
56 $inputlang = isset($languageinfo[$lang]['code']) && $languageinfo[$lang]['code'] != '' ? sprintf(" lang='%s' ", $languageinfo[$lang]['code']) : '';
57 $inputdir = isset($languageinfo[$lang]['rtl']) && $languageinfo[$lang]['rtl'] === true ? " dir='rtl' " : '';
58 foreach($phrases as $id => $phrase) {
59 if (sizeof($phrase['notes']) > 0 && trim(strtolower($phrase['phrase']['desc'])) != "deprecated") {
60 printf("<h3>%s</h3>", $phrase['phrase']['id']);
61
62 if (isset($phrase['phrase']['desc']))
63 printf("Description: %s<br />\n", $phrase['phrase']['desc']);
64 if (isset($phrase['phrase']['user']) && $phrase['phrase']['user'] != '')
65 printf("User: %s<br />\n", $phrase['phrase']['user']);
Solomon Peachya0eef362020-04-02 10:05:23 -040066
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000067 if (sizeof($phrase['notes']) > 0) {
68 print("<div class='note'>");
69 foreach($phrase['notes'] as $line) {
70 printf("%s<br />\n", htmlspecialchars($line));
71 }
72 print("</div>");
73 }
Solomon Peachya0eef362020-04-02 10:05:23 -040074
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000075 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']);
76 foreach($phrase['source'] as $target => $string) {
77 // Figure out what to put in the translated string
78 if (isset($english[$id]['dest'][$target]) && ($english[$id]['dest'][$target] == '' || $english[$id]['dest'][$target] == 'none')) {
79 $translated_value = $phrase['dest'][$target] = $english[$id]['dest'][$target];
80 }
81 elseif (isset($phrase['dest'][$target]) && $phrase['dest'][$target] != '' && $phrase['dest'][$target] != 'none') {
82 $translated_value = $phrase['dest'][$target];
Solomon Peachya0eef362020-04-02 10:05:23 -040083 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000084 else {
85 $translated_value = '';
86 }
Solomon Peachya0eef362020-04-02 10:05:23 -040087
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000088 // Figure out whether to set the translated value readonly
89 if (
90 // If english string is either unset, '' or none
91 (!isset($english[$id]['source'][$target]) || $english[$id]['source'][$target] == '' || $english[$id]['source'][$target] == 'none')
92 &&
93 // And destination is either unset or set to '' or none
94 (!isset($phrase['dest'][$target]) || ($phrase['dest'][$target] == '' || $phrase['dest'][$target] == 'none'))
95 ) {
96 $translated_readonly = 'readonly="readonly" class="readonly"';
97 }
98 else {
99 $translated_readonly = '';
100 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400101
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000102 // Figure out what to put in the voice string
103 if (isset($english[$id]['voice'][$target]) && ($english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')) {
104 $voice_value = $phrase['voice'][$target] = $english[$id]['voice'][$target];
105 }
106 elseif (isset($phrase['voice'][$target]) && $phrase['voice'][$target] != '' && $phrase['voice'][$target] != 'none') {
107 $voice_value = $phrase['voice'][$target];
108 }
109 else {
110 $voice_value = '';
111 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400112
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000113 // Figure out whether to set the voice value readonly
114 if (
115 // If english voice is either unset, '' or none
116 (!isset($english[$id]['voice'][$target]) || $english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')
117 &&
118 // And voice is not set, or set to '' or none
119 (!isset($phrase['voice'][$target]) || ($phrase['voice'][$target] == '' || $phrase['voice'][$target] == 'none'))
120 ) {
121 $voice_readonly = 'readonly="readonly" class="readonly"';
122 }
123 else {
124 $voice_readonly = '';
125 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400126
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000127 print("<tr>");
128 printf("<td>%s</td><td>%s</td><td><input %s %s name='phrases[%s][dest][%s]' size='40' type='text' value='%s' %s /></td>",
129 htmlspecialchars($target),
130 htmlspecialchars($string),
131 $inputlang,
132 $inputdir,
133 htmlspecialchars($id),
134 htmlspecialchars($target),
135 htmlspecialchars($translated_value, ENT_QUOTES),
136 $translated_readonly
137 );
Solomon Peachya0eef362020-04-02 10:05:23 -0400138
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000139 if (!isset($english[$id]['voice'][$target])) {
140 print("<td colspan='2'></td>");
141 }
142 else {
143 printf("<td>%s</td><td><input %s %s name='phrases[%s][voice][%s]' size='40' type='text' value='%s' %s /></td>",
144 htmlspecialchars(isset($english[$id]['voice'][$target]) ? $english[$id]['voice'][$target] : ''),
145 $inputlang,
146 $inputdir,
147 htmlspecialchars($id),
148 htmlspecialchars($target),
149 htmlspecialchars($voice_value, ENT_QUOTES),
150 $voice_readonly
151 );
152 }
153 print("</tr>\n");
154 }
155 print("</table>");
156 }
157 elseif (trim(strtolower($phrase['phrase']['desc'])) == "deprecated") {
158 printf("<input type='hidden' name='phrases[%s][dest][*]' value='' /><input type='hidden' name='phrases[%s][dest][*]' value='' />",
159 htmlspecialchars($id),
160 htmlspecialchars($id)
161 );
162 }
163 }
164echo <<<END
165<input type="submit" value="Finish translating" style="margin-top: 1em" />
166</form>
167<p>
168When you click this button, you will be sent a Rockbox language file. If you are
169satisfied with your changes, you're<!-- ' --> encouraged to submit this file in
Solomon Peachy5a27db82020-04-22 23:15:19 -0400170the <a href="//www.rockbox.org/tracker/newtask/proj1">Rockbox patch
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000171tracker.</a>
Solomon Peachya0eef362020-04-02 10:05:23 -0400172</p>
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000173END;
174}
175
176print_head();
177edit($_REQUEST['lang']);
178print_foot();
179?>