diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2008-04-10 09:40:04 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2008-04-10 09:40:04 +0000 |
| commit | 39efc6af370301529d830f39a6443423946043bf (patch) | |
| tree | 44a3336b948f2fbab39b52269ccc68d5d43c5f95 /translator/index.php | |
| parent | e0b3973c057011a01d0a371d54b102ac29d62270 (diff) | |
Putting translator under version control
git-svn-id: https://svn.roundcube.net/trunk@1276 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'translator/index.php')
| -rw-r--r-- | translator/index.php | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/translator/index.php b/translator/index.php new file mode 100644 index 000000000..1f09734fb --- /dev/null +++ b/translator/index.php @@ -0,0 +1,134 @@ +<?php header("Content-Type: text/html; charset=UTF-8"); ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et"> +<head> +<title>RoundCube Translator</title> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<link rel="stylesheet" href="styles.css" type="text/css" media="screen" /> +</head> +<body> + +<h2 id="pageheader">RoundCube (Live) Translator</h2> + +<?php include('func.php'); ?> + +<form method="post" action="<?=$_SERVER['PHP_SELF']?>"> +<fieldset> +<legend>What to translate</legend> + +<?php echo lang_selection($lang); ?> + +<select name="file"> + <option value="labels.inc"<?=($file=='labels.inc'?' selected':'')?>>labels.inc</option> + <option value="messages.inc"<?=($file=='messages.inc'?' selected':'')?>>messages.inc</option> +</select> + +<div> +<input type="checkbox" name="trans" id="trans" value="1"<?=($translated?' checked':'')?> /> +<label for="trans">Show translated texts</label> +</div> + +<p><input type="submit" class="button" value="Select" /></p> +</fieldset> +</form> + +<div id="translations"> +<form method="post" action="<?=$_SERVER['PHP_SELF']?>"> +<input type="hidden" name="save" value="1" /> +<?php + +if (!empty($lang) && !empty($file)) +{ + echo '<input type="hidden" name="lang" value="'.$lang.'" /><input type="hidden" name="file" value="'.$file.'" />'; + echo '<input type="hidden" name="trans" value="'.($translated?'1':'').'" />'; + echo '<table border="0" cellspacing="0" class="translist" summary="">'; + echo '<thead><tr><td>Label</td><td>Original</td><td>Translation</td></tr></thead><tbody>'; + + if ($lang != "_NEW_") + @include(update_from_svn($lang, $file)); + + if (!empty($labels)) + $edit_values = $labels; + else if (!empty($messages)) + $edit_values = $messages; + else + $edit_values = array(); + + $count = 0; + foreach($orig_values as $t_key => $t_value) + { + // skip translated lines + if(!$translated && !empty($edit_values[$t_key])) + continue; + + if ($post_value = get_input_value('t_'.$t_key)) + $edit_values[$t_key] = $post_value; + + echo '<tr class="'.(empty($edit_values[$t_key]) ? 'untranslated' : '')."\">\n"; + echo '<td class="key">'.htmlspecialchars($t_key).'</td>'; + echo '<td class="original">'.htmlspecialchars($t_value).'</td>'; + echo '<td><input name="t_'.$t_key.'" value="'.(!empty($edit_values[$t_key]) ? htmlspecialchars($edit_values[$t_key]) : "").'" size="60" />'; + echo "</td>\n</tr>\n"; + + $count++; + } + + if (!$count) + echo '<tr><td colspan="3"><em>No new texts to translate</em></td></tr>'; + + echo "</tbody></table>\n"; + echo '<p><input type="submit" class="button" name="translate" value="Create translation"/></p>'; + +} + +?> +</form> +</div> + +<?php + +if (isset($_POST["save"]) && $file && $lang) +{ + $array = $file == "messages.inc" ? '$messages' : '$labels'; + $fpath = $lang != "_NEW_" ? update_from_svn($lang, $file) : 'nope'; + + if (!strstr($fpath, 'http') && !is_file($fpath)) + $fpath = realpath("./$file"); + + echo '<div id="resultsbox">'."<h3>Localization file</h3>\n"; + echo '<form id="select_all" action="./"> + <textarea id="results" name="text_area" rows="'.min(30, count($orig_values)).'" cols="130">'; + + if ($fpath && ($fp = fopen($fpath, 'r'))) + { + while (!feof($fp)) + { + $line = fgets($fp); + echo htmlspecialchars(str_replace('#lang', $lang, rtrim($line))) . "\n"; + if (strstr($line, $array)) + break; + } + } + else + { + echo "<?php\n"; + echo $array . " = array();\n"; + } + + foreach($orig_values as $t_key => $t_value) + { + $t_value = get_input_value('t_'.$t_key); + if (empty($t_value) && isset($edit_values[$t_key])) + $t_value = $edit_values[$t_key]; + if (!empty($t_value)) + echo $array . "['$t_key'] = '" . addslashes(htmlspecialchars($t_value, ENT_COMPAT, 'UTF-8')) . "';\n"; + } + + echo "\n?></textarea>\n"; + 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>'; + echo "\n</form></div>"; +} + +?> +</body> +</html> |
