| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | ob_start(); |
|---|
| 4 | |
|---|
| 5 | require_once 'func.php'; |
|---|
| 6 | |
|---|
| 7 | if (isset($_POST["download"]) && $file && $lang) |
|---|
| 8 | { |
|---|
| 9 | ob_end_clean(); |
|---|
| 10 | |
|---|
| 11 | header("Content-Type: text/plain; charset=UTF-8"); |
|---|
| 12 | header("Cache-Control: private"); |
|---|
| 13 | header("Content-Disposition: attachment; filename=\"{$file}\""); |
|---|
| 14 | |
|---|
| 15 | echo build_localization($lang, $file); |
|---|
| 16 | exit; |
|---|
| 17 | } |
|---|
| 18 | else |
|---|
| 19 | header("Content-Type: text/html; charset=UTF-8"); |
|---|
| 20 | |
|---|
| 21 | ob_end_clean(); |
|---|
| 22 | |
|---|
| 23 | ?> |
|---|
| 24 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 25 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et"> |
|---|
| 26 | <head> |
|---|
| 27 | <title>RoundCube Translator</title> |
|---|
| 28 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 29 | <link rel="stylesheet" href="styles.css" type="text/css" media="screen" /> |
|---|
| 30 | </head> |
|---|
| 31 | <body> |
|---|
| 32 | |
|---|
| 33 | <div id="banner"> |
|---|
| 34 | <div class="banner-bg"></div> |
|---|
| 35 | <div class="banner-logo"><a href="http://roundcube.net"><img src="images/rcube_logo.gif" width="210" height="55" border="0" alt="Roundcube - Open source webmail project" /></a></div> |
|---|
| 36 | <h1>Roundcube (Live) Translator</h1> |
|---|
| 37 | </div> |
|---|
| 38 | |
|---|
| 39 | <div id="bodycontent"> |
|---|
| 40 | |
|---|
| 41 | <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> |
|---|
| 42 | <fieldset> |
|---|
| 43 | <legend>What to translate</legend> |
|---|
| 44 | |
|---|
| 45 | <?php echo lang_selection($lang); ?> |
|---|
| 46 | |
|---|
| 47 | <select name="file"> |
|---|
| 48 | <option value="labels.inc"<?php echo ($file=='labels.inc'?' selected':''); ?>>labels.inc</option> |
|---|
| 49 | <option value="messages.inc"<?php echo ($file=='messages.inc'?' selected':''); ?>>messages.inc</option> |
|---|
| 50 | </select> |
|---|
| 51 | |
|---|
| 52 | <div> |
|---|
| 53 | <input type="checkbox" name="trans" id="trans" value="1"<?php echo ($translated?' checked':''); ?> /> |
|---|
| 54 | <label for="trans">Show translated texts</label> |
|---|
| 55 | </div> |
|---|
| 56 | |
|---|
| 57 | <p><input type="submit" class="button" value="Select" /></p> |
|---|
| 58 | </fieldset> |
|---|
| 59 | </form> |
|---|
| 60 | |
|---|
| 61 | <div id="translations"> |
|---|
| 62 | <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> |
|---|
| 63 | <input type="hidden" name="save" value="1" /> |
|---|
| 64 | <?php |
|---|
| 65 | |
|---|
| 66 | if (!empty($lang) && !empty($file)) |
|---|
| 67 | { |
|---|
| 68 | echo '<input type="hidden" name="lang" value="'.$lang.'" /><input type="hidden" name="file" value="'.$file.'" />'; |
|---|
| 69 | echo '<input type="hidden" name="trans" value="'.($translated?'1':'').'" />'; |
|---|
| 70 | echo '<table border="0" cellspacing="0" class="translist" summary="">'; |
|---|
| 71 | echo '<thead><tr><td>Label</td><td>Original</td><td>Translation</td></tr></thead><tbody>'; |
|---|
| 72 | |
|---|
| 73 | $count = 0; |
|---|
| 74 | foreach($orig_values as $t_key => $t_value) |
|---|
| 75 | { |
|---|
| 76 | // skip translated lines |
|---|
| 77 | if(!$translated && !empty($edit_values[$t_key])) |
|---|
| 78 | continue; |
|---|
| 79 | |
|---|
| 80 | if ($post_value = get_input_value('t_'.$t_key)) |
|---|
| 81 | $edit_values[$t_key] = $post_value; |
|---|
| 82 | |
|---|
| 83 | echo '<tr class="'.(empty($edit_values[$t_key]) ? 'untranslated' : '')."\">\n"; |
|---|
| 84 | echo '<td class="key">'.htmlspecialchars($t_key).'</td>'; |
|---|
| 85 | echo '<td class="original">'.htmlspecialchars($t_value).'</td>'; |
|---|
| 86 | echo '<td><input name="t_'.$t_key.'" value="'.(!empty($edit_values[$t_key]) ? htmlspecialchars($edit_values[$t_key]) : "").'" size="60" />'; |
|---|
| 87 | echo "</td>\n</tr>\n"; |
|---|
| 88 | |
|---|
| 89 | $count++; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | if (!$count) |
|---|
| 93 | echo '<tr><td colspan="3"><em>No new texts to translate</em></td></tr>'; |
|---|
| 94 | |
|---|
| 95 | echo "</tbody></table>\n"; |
|---|
| 96 | echo '<p><br /><input type="submit" class="button" name="translate" value="Create translation" />'; |
|---|
| 97 | echo '<span style="padding-left:1.5em"><input type="checkbox" name="download" value="1" checked="checked" /> Download directly</a></p>'; |
|---|
| 98 | echo '<p class="hint">Save the localization file and post it to the <a href="http://lists.roundcube.net/dev">dev-mailing list</a></p>'; |
|---|
| 99 | |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | ?> |
|---|
| 103 | </form> |
|---|
| 104 | </div> |
|---|
| 105 | |
|---|
| 106 | <?php |
|---|
| 107 | |
|---|
| 108 | if (isset($_POST["save"]) && $file && $lang) |
|---|
| 109 | { |
|---|
| 110 | echo '<div id="resultsbox">'."<h3>Localization file</h3>\n"; |
|---|
| 111 | echo '<form id="select_all" action="./"> |
|---|
| 112 | <textarea id="results" name="text_area" rows="'.min(30, count($orig_values)).'" cols="130">'; |
|---|
| 113 | echo htmlspecialchars(build_localization($lang, $file), ENT_COMPAT, 'UTF-8'); |
|---|
| 114 | echo "</textarea>\n"; |
|---|
| 115 | echo '<p><input id="hilight" class="button" type="button" value="Select all" onclick="javascript:this.form.text_area.focus();this.form.text_area.select();" /></p>'; |
|---|
| 116 | echo "\n</form></div>"; |
|---|
| 117 | } |
|---|
| 118 | else if (empty($file)) |
|---|
| 119 | { |
|---|
| 120 | echo '<h4>Current completeness status</h4>'; |
|---|
| 121 | echo '<div>'.localization_stats().'</div>'; |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | ?> |
|---|
| 125 | </div> |
|---|
| 126 | |
|---|
| 127 | </body> |
|---|
| 128 | </html> |
|---|