blob: cc5c11895babe0e11940028c5b3721b231af1219 [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
Solomon Peachy7f1ee2d2021-12-17 10:41:27 -050024function edit($lang, $all = false) {
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000025 $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 Peachy7f1ee2d2021-12-17 10:41:27 -050049 $phrases = parselangfile(sprintf("scratch/%s.lang.update", $lang), $all);
50 $english = parselangfile(sprintf("scratch/%s.lang.update", 'english'), $all);
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 &&
Solomon Peachy23e37872021-09-28 17:50:55 -0400118 ($id != 'VOICE_NUMERIC_TENS_SWAP_SEPARATOR')
119 &&
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000120 // And voice is not set, or set to '' or none
121 (!isset($phrase['voice'][$target]) || ($phrase['voice'][$target] == '' || $phrase['voice'][$target] == 'none'))
122 ) {
123 $voice_readonly = 'readonly="readonly" class="readonly"';
124 }
125 else {
126 $voice_readonly = '';
127 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400128
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000129 print("<tr>");
130 printf("<td>%s</td><td>%s</td><td><input %s %s name='phrases[%s][dest][%s]' size='40' type='text' value='%s' %s /></td>",
131 htmlspecialchars($target),
132 htmlspecialchars($string),
133 $inputlang,
134 $inputdir,
135 htmlspecialchars($id),
136 htmlspecialchars($target),
137 htmlspecialchars($translated_value, ENT_QUOTES),
138 $translated_readonly
139 );
Solomon Peachya0eef362020-04-02 10:05:23 -0400140
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000141 if (!isset($english[$id]['voice'][$target])) {
142 print("<td colspan='2'></td>");
143 }
144 else {
145 printf("<td>%s</td><td><input %s %s name='phrases[%s][voice][%s]' size='40' type='text' value='%s' %s /></td>",
146 htmlspecialchars(isset($english[$id]['voice'][$target]) ? $english[$id]['voice'][$target] : ''),
147 $inputlang,
148 $inputdir,
149 htmlspecialchars($id),
150 htmlspecialchars($target),
151 htmlspecialchars($voice_value, ENT_QUOTES),
152 $voice_readonly
153 );
154 }
155 print("</tr>\n");
156 }
157 print("</table>");
158 }
159 elseif (trim(strtolower($phrase['phrase']['desc'])) == "deprecated") {
160 printf("<input type='hidden' name='phrases[%s][dest][*]' value='' /><input type='hidden' name='phrases[%s][dest][*]' value='' />",
161 htmlspecialchars($id),
162 htmlspecialchars($id)
163 );
164 }
165 }
166echo <<<END
167<input type="submit" value="Finish translating" style="margin-top: 1em" />
168</form>
169<p>
170When you click this button, you will be sent a Rockbox language file. If you are
171satisfied with your changes, you're<!-- ' --> encouraged to submit this file in
Solomon Peachy5a27db82020-04-22 23:15:19 -0400172the <a href="//www.rockbox.org/tracker/newtask/proj1">Rockbox patch
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000173tracker.</a>
Solomon Peachya0eef362020-04-02 10:05:23 -0400174</p>
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000175END;
176}
177
178print_head();
Solomon Peachy7f1ee2d2021-12-17 10:41:27 -0500179edit($_REQUEST['lang'], $_REQUEST['all']);
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000180print_foot();
181?>