blob: c5f5c47e14bf0a53871e72d07c7855f9a62f6df8 [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>
38<p>
39If a field is read-only, it means that this string is not meant to be translated
40and you should leave it as-is. The special string "none" is not meant to be
41translated, so if you see it in the english version, put "none" in the
42translation as well.
43</p>
44<form action="submit.php" method="post">
45<input type="hidden" name="lang" value="$lang" />
46END;
47
Jonas Häggqvist04e454b2010-01-31 01:50:52 +000048 $phrases = parselangfile(sprintf("rockbox/apps/lang/%s.lang.update", $lang));
49 $english = parselangfile(sprintf("rockbox/apps/lang/%s.lang.update", 'english'));
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000050 if ($phrases === false || $english === false) {
51 printf("<strong>The file %s.lang doesn't exist, or something else went terribly wrong</strong>", $lang);
52 return false;
53 }
54
55 $inputlang = isset($languageinfo[$lang]['code']) && $languageinfo[$lang]['code'] != '' ? sprintf(" lang='%s' ", $languageinfo[$lang]['code']) : '';
56 $inputdir = isset($languageinfo[$lang]['rtl']) && $languageinfo[$lang]['rtl'] === true ? " dir='rtl' " : '';
57 foreach($phrases as $id => $phrase) {
58 if (sizeof($phrase['notes']) > 0 && trim(strtolower($phrase['phrase']['desc'])) != "deprecated") {
59 printf("<h3>%s</h3>", $phrase['phrase']['id']);
60
61 if (isset($phrase['phrase']['desc']))
62 printf("Description: %s<br />\n", $phrase['phrase']['desc']);
63 if (isset($phrase['phrase']['user']) && $phrase['phrase']['user'] != '')
64 printf("User: %s<br />\n", $phrase['phrase']['user']);
Solomon Peachya0eef362020-04-02 10:05:23 -040065
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000066 if (sizeof($phrase['notes']) > 0) {
67 print("<div class='note'>");
68 foreach($phrase['notes'] as $line) {
69 printf("%s<br />\n", htmlspecialchars($line));
70 }
71 print("</div>");
72 }
Solomon Peachya0eef362020-04-02 10:05:23 -040073
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000074 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']);
75 foreach($phrase['source'] as $target => $string) {
76 // Figure out what to put in the translated string
77 if (isset($english[$id]['dest'][$target]) && ($english[$id]['dest'][$target] == '' || $english[$id]['dest'][$target] == 'none')) {
78 $translated_value = $phrase['dest'][$target] = $english[$id]['dest'][$target];
79 }
80 elseif (isset($phrase['dest'][$target]) && $phrase['dest'][$target] != '' && $phrase['dest'][$target] != 'none') {
81 $translated_value = $phrase['dest'][$target];
Solomon Peachya0eef362020-04-02 10:05:23 -040082 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000083 else {
84 $translated_value = '';
85 }
Solomon Peachya0eef362020-04-02 10:05:23 -040086
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000087 // Figure out whether to set the translated value readonly
88 if (
89 // If english string is either unset, '' or none
90 (!isset($english[$id]['source'][$target]) || $english[$id]['source'][$target] == '' || $english[$id]['source'][$target] == 'none')
91 &&
92 // And destination is either unset or set to '' or none
93 (!isset($phrase['dest'][$target]) || ($phrase['dest'][$target] == '' || $phrase['dest'][$target] == 'none'))
94 ) {
95 $translated_readonly = 'readonly="readonly" class="readonly"';
96 }
97 else {
98 $translated_readonly = '';
99 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400100
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000101 // Figure out what to put in the voice string
102 if (isset($english[$id]['voice'][$target]) && ($english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')) {
103 $voice_value = $phrase['voice'][$target] = $english[$id]['voice'][$target];
104 }
105 elseif (isset($phrase['voice'][$target]) && $phrase['voice'][$target] != '' && $phrase['voice'][$target] != 'none') {
106 $voice_value = $phrase['voice'][$target];
107 }
108 else {
109 $voice_value = '';
110 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400111
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000112 // Figure out whether to set the voice value readonly
113 if (
114 // If english voice is either unset, '' or none
115 (!isset($english[$id]['voice'][$target]) || $english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')
116 &&
117 // And voice is not set, or set to '' or none
118 (!isset($phrase['voice'][$target]) || ($phrase['voice'][$target] == '' || $phrase['voice'][$target] == 'none'))
119 ) {
120 $voice_readonly = 'readonly="readonly" class="readonly"';
121 }
122 else {
123 $voice_readonly = '';
124 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400125
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000126 print("<tr>");
127 printf("<td>%s</td><td>%s</td><td><input %s %s name='phrases[%s][dest][%s]' size='40' type='text' value='%s' %s /></td>",
128 htmlspecialchars($target),
129 htmlspecialchars($string),
130 $inputlang,
131 $inputdir,
132 htmlspecialchars($id),
133 htmlspecialchars($target),
134 htmlspecialchars($translated_value, ENT_QUOTES),
135 $translated_readonly
136 );
Solomon Peachya0eef362020-04-02 10:05:23 -0400137
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000138 if (!isset($english[$id]['voice'][$target])) {
139 print("<td colspan='2'></td>");
140 }
141 else {
142 printf("<td>%s</td><td><input %s %s name='phrases[%s][voice][%s]' size='40' type='text' value='%s' %s /></td>",
143 htmlspecialchars(isset($english[$id]['voice'][$target]) ? $english[$id]['voice'][$target] : ''),
144 $inputlang,
145 $inputdir,
146 htmlspecialchars($id),
147 htmlspecialchars($target),
148 htmlspecialchars($voice_value, ENT_QUOTES),
149 $voice_readonly
150 );
151 }
152 print("</tr>\n");
153 }
154 print("</table>");
155 }
156 elseif (trim(strtolower($phrase['phrase']['desc'])) == "deprecated") {
157 printf("<input type='hidden' name='phrases[%s][dest][*]' value='' /><input type='hidden' name='phrases[%s][dest][*]' value='' />",
158 htmlspecialchars($id),
159 htmlspecialchars($id)
160 );
161 }
162 }
163echo <<<END
164<input type="submit" value="Finish translating" style="margin-top: 1em" />
165</form>
166<p>
167When you click this button, you will be sent a Rockbox language file. If you are
168satisfied with your changes, you're<!-- ' --> encouraged to submit this file in
Solomon Peachy5a27db82020-04-22 23:15:19 -0400169the <a href="//www.rockbox.org/tracker/newtask/proj1">Rockbox patch
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000170tracker.</a>
Solomon Peachya0eef362020-04-02 10:05:23 -0400171</p>
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000172END;
173}
174
175print_head();
176edit($_REQUEST['lang']);
177print_foot();
178?>