Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 1 | <?php |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 2 | /************************************************************************ |
| 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 | |
| 21 | error_reporting(E_ALL); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 22 | require_once('common.php'); |
| 23 | |
Solomon Peachy | 7f1ee2d | 2021-12-17 10:41:27 -0500 | [diff] [blame^] | 24 | function edit($lang, $all = false) { |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 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> |
| 32 | Go through this list and follow the instructions given <span class="note">marked in dark red</span>. When |
| 33 | you're done, press the "Finish translating" button at the bottom of this page.<!-- ' --> |
| 34 | You will then be sent a patch file with your changes. Submit this file |
Solomon Peachy | 5a27db8 | 2020-04-22 23:15:19 -0400 | [diff] [blame] | 35 | to Rockbox on the <a href="//www.rockbox.org/tracker/newtask/proj1">patch |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 36 | tracker</a>. |
| 37 | </p> |
Solomon Peachy | ededdf6 | 2020-05-21 21:24:55 -0400 | [diff] [blame] | 38 | <p><b>Please note we will need your full legal name in order to accept any patches, including translation updates!</b></p> |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 39 | <p> |
| 40 | If a field is read-only, it means that this string is not meant to be translated |
| 41 | and you should leave it as-is. The special string "none" is not meant to be |
| 42 | translated, so if you see it in the english version, put "none" in the |
| 43 | translation as well. |
| 44 | </p> |
| 45 | <form action="submit.php" method="post"> |
| 46 | <input type="hidden" name="lang" value="$lang" /> |
| 47 | END; |
| 48 | |
Solomon Peachy | 7f1ee2d | 2021-12-17 10:41:27 -0500 | [diff] [blame^] | 49 | $phrases = parselangfile(sprintf("scratch/%s.lang.update", $lang), $all); |
| 50 | $english = parselangfile(sprintf("scratch/%s.lang.update", 'english'), $all); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 51 | 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 Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 66 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 67 | 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 Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 74 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 75 | 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 Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 83 | } |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 84 | else { |
| 85 | $translated_value = ''; |
| 86 | } |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 87 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 88 | // 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 Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 101 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 102 | // 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 Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 112 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 113 | // 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 Peachy | 23e3787 | 2021-09-28 17:50:55 -0400 | [diff] [blame] | 118 | ($id != 'VOICE_NUMERIC_TENS_SWAP_SEPARATOR') |
| 119 | && |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 120 | // 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 Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 128 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 129 | 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 Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 140 | |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 141 | 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 | } |
| 166 | echo <<<END |
| 167 | <input type="submit" value="Finish translating" style="margin-top: 1em" /> |
| 168 | </form> |
| 169 | <p> |
| 170 | When you click this button, you will be sent a Rockbox language file. If you are |
| 171 | satisfied with your changes, you're<!-- ' --> encouraged to submit this file in |
Solomon Peachy | 5a27db8 | 2020-04-22 23:15:19 -0400 | [diff] [blame] | 172 | the <a href="//www.rockbox.org/tracker/newtask/proj1">Rockbox patch |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 173 | tracker.</a> |
Solomon Peachy | a0eef36 | 2020-04-02 10:05:23 -0400 | [diff] [blame] | 174 | </p> |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 175 | END; |
| 176 | } |
| 177 | |
| 178 | print_head(); |
Solomon Peachy | 7f1ee2d | 2021-12-17 10:41:27 -0500 | [diff] [blame^] | 179 | edit($_REQUEST['lang'], $_REQUEST['all']); |
Jonas Häggqvist | b632ed1 | 2010-01-30 02:04:47 +0000 | [diff] [blame] | 180 | print_foot(); |
| 181 | ?> |