blob: 8298f96a7ccf77209e1b18c7a6fd30ce62c97e03 [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
Solomon Peachy4199f172024-05-15 14:09:39 -040036tracker</a>.
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000037</p>
Solomon Peachy0011c012024-05-15 12:29:22 -040038<p>Other notes:</p>
39<ul>
Solomon Peachy4199f172024-05-15 14:09:39 -040040<li><b>We will need your full legal name in order to accept any patches, including translation updates!</b></li>
41<li>If a field is read-only, it means that this string is not meant to be translated and will not be editable.</li>
42<li>The special string "none" is not meant to be translated, and will not allow edits.</li>
Solomon Peachyd6684f02024-05-16 21:57:21 -040043<li>Voice strings cannot include C format specifiers (eg '%d') and other suspicious characters such as quotation marks or ellipses.</li>
Solomon Peachy4199f172024-05-15 14:09:39 -040044<li>Normally, if a translated string is the same as the original English, this is treated as an error. To bypass this test for specific strings, please prepend them with '~'. (For example, instead of 'something' you would write '~something')</li>
Solomon Peachybec1a152024-05-17 08:32:01 -040045<li>There is a set of corrections automatically applied to voice strings; for example spelling out common acronyms or fixing mispronounciations in a TTS engine. See <a href="https://git.rockbox.org/cgit/rockbox.git/tree/tools/voice-corrections.txt">voice-corrections.txt</a> for specifics.</li>
Solomon Peachy0011c012024-05-15 12:29:22 -040046</ul>
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000047<form action="submit.php" method="post">
48<input type="hidden" name="lang" value="$lang" />
49END;
50
Solomon Peachy7f1ee2d2021-12-17 10:41:27 -050051 $phrases = parselangfile(sprintf("scratch/%s.lang.update", $lang), $all);
52 $english = parselangfile(sprintf("scratch/%s.lang.update", 'english'), $all);
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000053 if ($phrases === false || $english === false) {
54 printf("<strong>The file %s.lang doesn't exist, or something else went terribly wrong</strong>", $lang);
55 return false;
56 }
57
58 $inputlang = isset($languageinfo[$lang]['code']) && $languageinfo[$lang]['code'] != '' ? sprintf(" lang='%s' ", $languageinfo[$lang]['code']) : '';
59 $inputdir = isset($languageinfo[$lang]['rtl']) && $languageinfo[$lang]['rtl'] === true ? " dir='rtl' " : '';
60 foreach($phrases as $id => $phrase) {
Solomon Peachya530b302024-05-16 22:34:00 -040061 $foo = array();
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000062 if (sizeof($phrase['notes']) > 0 && trim(strtolower($phrase['phrase']['desc'])) != "deprecated") {
63 printf("<h3>%s</h3>", $phrase['phrase']['id']);
64
65 if (isset($phrase['phrase']['desc']))
66 printf("Description: %s<br />\n", $phrase['phrase']['desc']);
67 if (isset($phrase['phrase']['user']) && $phrase['phrase']['user'] != '')
68 printf("User: %s<br />\n", $phrase['phrase']['user']);
Solomon Peachya0eef362020-04-02 10:05:23 -040069
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000070 if (sizeof($phrase['notes']) > 0) {
71 print("<div class='note'>");
72 foreach($phrase['notes'] as $line) {
Solomon Peachya530b302024-05-16 22:34:00 -040073 if (preg_match('/The <(.+)> section for \'.+:(.*)\'.+/', $line, $matches)) {
74 $foo["$matches[1]:$matches[2]"] = 1;
Solomon Peachyfad4ecd2024-05-17 08:01:10 -040075 } elseif (preg_match('/This phrase is missing/', $line)) {
76 $foo["dest"] = 1;
77 $foo["voice"] = 1;
Solomon Peachya530b302024-05-16 22:34:00 -040078 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000079 printf("%s<br />\n", htmlspecialchars($line));
80 }
81 print("</div>");
82 }
Solomon Peachya0eef362020-04-02 10:05:23 -040083
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000084 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']);
85 foreach($phrase['source'] as $target => $string) {
86 // Figure out what to put in the translated string
87 if (isset($english[$id]['dest'][$target]) && ($english[$id]['dest'][$target] == '' || $english[$id]['dest'][$target] == 'none')) {
88 $translated_value = $phrase['dest'][$target] = $english[$id]['dest'][$target];
89 }
90 elseif (isset($phrase['dest'][$target]) && $phrase['dest'][$target] != '' && $phrase['dest'][$target] != 'none') {
91 $translated_value = $phrase['dest'][$target];
Solomon Peachya0eef362020-04-02 10:05:23 -040092 }
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000093 else {
94 $translated_value = '';
95 }
Solomon Peachya0eef362020-04-02 10:05:23 -040096
Jonas Häggqvistb632ed12010-01-30 02:04:47 +000097 // Figure out whether to set the translated value readonly
98 if (
99 // If english string is either unset, '' or none
100 (!isset($english[$id]['source'][$target]) || $english[$id]['source'][$target] == '' || $english[$id]['source'][$target] == 'none')
101 &&
102 // And destination is either unset or set to '' or none
103 (!isset($phrase['dest'][$target]) || ($phrase['dest'][$target] == '' || $phrase['dest'][$target] == 'none'))
104 ) {
105 $translated_readonly = 'readonly="readonly" class="readonly"';
106 }
107 else {
108 $translated_readonly = '';
109 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400110
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000111 // Figure out what to put in the voice string
112 if (isset($english[$id]['voice'][$target]) && ($english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')) {
113 $voice_value = $phrase['voice'][$target] = $english[$id]['voice'][$target];
114 }
115 elseif (isset($phrase['voice'][$target]) && $phrase['voice'][$target] != '' && $phrase['voice'][$target] != 'none') {
116 $voice_value = $phrase['voice'][$target];
117 }
118 else {
119 $voice_value = '';
120 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400121
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000122 // Figure out whether to set the voice value readonly
123 if (
124 // If english voice is either unset, '' or none
125 (!isset($english[$id]['voice'][$target]) || $english[$id]['voice'][$target] == '' || $english[$id]['voice'][$target] == 'none')
126 &&
Solomon Peachy23e37872021-09-28 17:50:55 -0400127 ($id != 'VOICE_NUMERIC_TENS_SWAP_SEPARATOR')
128 &&
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000129 // And voice is not set, or set to '' or none
130 (!isset($phrase['voice'][$target]) || ($phrase['voice'][$target] == '' || $phrase['voice'][$target] == 'none'))
131 ) {
132 $voice_readonly = 'readonly="readonly" class="readonly"';
133 }
134 else {
135 $voice_readonly = '';
136 }
Solomon Peachya0eef362020-04-02 10:05:23 -0400137
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000138 print("<tr>");
Solomon Peachyfad4ecd2024-05-17 08:01:10 -0400139 if (array_key_exists("dest:$target", $foo) ||
140 array_key_exists("dest", $foo)) {
Solomon Peachya530b302024-05-16 22:34:00 -0400141 $bgcolor='class="poor"';
142 } else {
143 $bgcolor='';
144 }
145
146 printf("<td>%s</td><td>%s</td><td $bgcolor><input %s %s name='phrases[%s][dest][%s]' size='40' type='text' value='%s' %s /></td>",
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000147 htmlspecialchars($target),
148 htmlspecialchars($string),
149 $inputlang,
150 $inputdir,
151 htmlspecialchars($id),
152 htmlspecialchars($target),
153 htmlspecialchars($translated_value, ENT_QUOTES),
154 $translated_readonly
155 );
Solomon Peachya0eef362020-04-02 10:05:23 -0400156
Solomon Peachyfad4ecd2024-05-17 08:01:10 -0400157 if (array_key_exists("voice:$target", $foo) ||
158 array_key_exists("voice", $foo)) {
Solomon Peachya530b302024-05-16 22:34:00 -0400159 $bgcolor='class="poor"';
160 } else {
161 $bgcolor='';
162 }
163
164
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000165 if (!isset($english[$id]['voice'][$target])) {
166 print("<td colspan='2'></td>");
167 }
168 else {
Solomon Peachya530b302024-05-16 22:34:00 -0400169 printf("<td>%s</td><td $bgcolor><input %s %s name='phrases[%s][voice][%s]' size='40' type='text' value='%s' %s /></td>",
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000170 htmlspecialchars(isset($english[$id]['voice'][$target]) ? $english[$id]['voice'][$target] : ''),
171 $inputlang,
172 $inputdir,
173 htmlspecialchars($id),
174 htmlspecialchars($target),
175 htmlspecialchars($voice_value, ENT_QUOTES),
176 $voice_readonly
177 );
178 }
179 print("</tr>\n");
180 }
181 print("</table>");
182 }
183 elseif (trim(strtolower($phrase['phrase']['desc'])) == "deprecated") {
184 printf("<input type='hidden' name='phrases[%s][dest][*]' value='' /><input type='hidden' name='phrases[%s][dest][*]' value='' />",
185 htmlspecialchars($id),
186 htmlspecialchars($id)
187 );
188 }
189 }
190echo <<<END
191<input type="submit" value="Finish translating" style="margin-top: 1em" />
192</form>
193<p>
194When you click this button, you will be sent a Rockbox language file. If you are
195satisfied with your changes, you're<!-- ' --> encouraged to submit this file in
Solomon Peachy5a27db82020-04-22 23:15:19 -0400196the <a href="//www.rockbox.org/tracker/newtask/proj1">Rockbox patch
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000197tracker.</a>
Solomon Peachya0eef362020-04-02 10:05:23 -0400198</p>
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000199END;
200}
201
202print_head();
Solomon Peachy7f1ee2d2021-12-17 10:41:27 -0500203edit($_REQUEST['lang'], $_REQUEST['all']);
Jonas Häggqvistb632ed12010-01-30 02:04:47 +0000204print_foot();
205?>