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 | |
| 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')
| -rw-r--r-- | translator/button.gif | bin | 0 -> 211 bytes | |||
| -rw-r--r-- | translator/favicon.ico | bin | 0 -> 1406 bytes | |||
| -rw-r--r-- | translator/func.php | 106 | ||||
| -rw-r--r-- | translator/index.php | 134 | ||||
| -rw-r--r-- | translator/labels.inc | 17 | ||||
| -rw-r--r-- | translator/localization/index.inc | 101 | ||||
| -rw-r--r-- | translator/messages.inc | 17 | ||||
| -rw-r--r-- | translator/robots.txt | 2 | ||||
| -rw-r--r-- | translator/styles.css | 85 |
9 files changed, 462 insertions, 0 deletions
diff --git a/translator/button.gif b/translator/button.gif Binary files differnew file mode 100644 index 000000000..e2191c910 --- /dev/null +++ b/translator/button.gif diff --git a/translator/favicon.ico b/translator/favicon.ico Binary files differnew file mode 100644 index 000000000..5a011f29e --- /dev/null +++ b/translator/favicon.ico diff --git a/translator/func.php b/translator/func.php new file mode 100644 index 000000000..ca37e8195 --- /dev/null +++ b/translator/func.php @@ -0,0 +1,106 @@ +<?php + +// define locations here +define('LANGDIR', './localization/'); // langdir location +define('LABELS', 'labels.inc'); // name of the labels file +define('MESSAGES', 'messages.inc'); // name of the messages file +define('ORIGINAL', 'en_US'); // always up-to-date language + +// ---- EOF conf ---- // + +function get_input_value($fname) +{ + $value = !empty($_REQUEST[$fname]) ? $_REQUEST[$fname] : ""; + + // strip slashes if magic_quotes enabled + if ((bool)get_magic_quotes_gpc()) + $value = stripslashes($value); + + // remove HTML tags if not allowed + $value = strip_tags($value); + + return $value; + } + + +function update_from_svn($lang, $file) +{ + $host = "svn.roundcube.net"; + $base = "/trunk/roundcubemail/program/localization/"; + + $lang_dir = $lang != "" ? $lang."/" : ""; + $lang_prefix = $lang != "" ? $lang."_" : ""; + + // check if original file is up to date + $stat = @stat(LANGDIR."$lang_prefix$file"); + if (!$stat || ($stat['mtime'] < time() - 3600)) + { + if ($fp = fsockopen("ssl://$host", 443, $err, $err_str)) + fwrite($fp, "GET $base$lang_dir$file HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n\r\n"); + + $headers = true; + if ($fp && !$err && ($fl = @fopen(LANGDIR."$lang_prefix$file", 'w'))) + { + // echo '<div class="console">Update from SVN: '.$lang_dir.$file.'</div>'; + while (!feof($fp)) + { + $line = fgets($fp, 4096); + if (trim($line) == "") + $headers = false; + if (!$headers) + fwrite($fl, $line); + } + + fclose($fp); + fclose($fl); + } + } + + if (is_file(LANGDIR."$lang_prefix$file")) + return LANGDIR."$lang_prefix$file"; + else + return false; +} + + +function lang_selection($lang) +{ + include(LANGDIR."index.inc"); + + $out = "<select name=\"lang\">\n<option value=\"_NEW_\">New Language</option>\n"; + foreach ($rcube_languages as $l_key => $l_value) + { + if ($l_key == ORIGINAL) + continue; + + $out .= '<option value="'.$l_key.'"'; + if ($l_key == $lang) $out .= ' selected'; + $out .= '>' . htmlspecialchars($l_value) . "</option>\n"; + } + $out .= "</select>"; + + return $out; +} + + +// -------- EOF func --------// + +$header = array(); +$orig_values = array(); +$labels = $messages = null; + +$file = get_input_value('file'); +$lang = get_input_value('lang'); +$translated = !empty($_REQUEST['trans']); + +if ($file && $lang) + include(update_from_svn(ORIGINAL, $file)); + +if ($file == 'labels.inc' && $labels) + $orig_values = $labels; +else if ($file == 'messages.inc' && $messages) + $orig_values = $messages; + +unset($labels, $messages); + +?>
\ No newline at end of file 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> diff --git a/translator/labels.inc b/translator/labels.inc new file mode 100644 index 000000000..b4b76e91f --- /dev/null +++ b/translator/labels.inc @@ -0,0 +1,17 @@ +<?php + +/* + +-----------------------------------------------------------------------+ + | language/#lang/labels.inc | + | | + | Language file of the RoundCube Webmail client | + | Copyright (C) 2006, RoundQube Dev. - Switzerland | + | Licensed under the GNU GPL | + | | + +-----------------------------------------------------------------------+ + | Author: | + +-----------------------------------------------------------------------+ + +*/ + +$labels = array(); diff --git a/translator/localization/index.inc b/translator/localization/index.inc new file mode 100644 index 000000000..f6437314a --- /dev/null +++ b/translator/localization/index.inc @@ -0,0 +1,101 @@ +<?php + +/* + +-----------------------------------------------------------------------+ + | program/localization/index.inc | + | | + | This file is part of the RoundCube Webmail client | + | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | + | Licensed under the GNU GPL | + | | + | PURPOSE: | + | Provide centralized location for keeping track of | + | available languages | + | | + +-----------------------------------------------------------------------+ + | Author: Thomas Bruederli <roundcube@gmail.com> | + +-----------------------------------------------------------------------+ + + $Id: index.inc 1247 2008-04-04 10:30:05Z thomasb $ + +*/ + + $rcube_languages = array( + 'sq_AL' => 'Albanian', + 'ar' => 'Arabic', + 'am' => 'Armenian', + 'bs_BA' => 'Bosnian (Bosanski)', + 'bg' => 'Bulgarian', + 'ca' => 'Català', + 'zh_CN' => 'Chinese (Simplified)', + 'zh_TW' => 'Chinese (Traditional)', + 'hr' => 'Croatian (Hrvatski)', + 'cz' => 'Czech', + 'da' => 'Dansk', + 'de_DE' => 'Deutsch (Deutsch)', + 'de_CH' => 'Deutsch (Schweiz)', + 'en_GB' => 'English (GB)', + 'en_US' => 'English (US)', + 'es' => 'Español', + 'eo' => 'Esperanto', + 'et_EE' => 'Estonian', + 'eu' => 'Euskara', + 'nl_BE' => 'Flemish', + 'fr' => 'Français', + 'gl' => 'Galego', + 'ge' => 'Georgian', + 'el' => 'Greek', + 'he' => 'Hebrew', + 'hi' => 'Hindi', + 'hu' => 'Hungarian', + 'is' => 'Icelandic', + 'id_ID' => 'Indonesian', + 'ga_IE' => 'Irish', + 'it' => 'Italiano', + 'ja' => 'Japanese (日本語)', + 'kr' => 'Korean', + 'ku' => 'Kurdish (Kurmancî)', + 'lv' => 'Latvian', + 'lt' => 'Lithuanian', + 'mk' => 'Macedonian', + 'ms_MY' => 'Malay', + 'nl_NL' => 'Nederlands', + 'ne' => 'Nepali', + 'nb_NO' => 'Norsk (bokmål)', + 'nn_NO' => 'Norsk (nynorsk)', + 'fa' => 'Persian', + 'pl' => 'Polski', + 'pt_BR' => 'Portuguese (Brazilian)', + 'pt_PT' => 'Portuguese (Standard)', + 'ro' => 'Romanian', + 'ru' => 'Russian', + 'sr_cyrillic' => 'Serbian Cyrillic', + 'sr_latin' => 'Serbian Latin', + 'si' => 'Sinhala', + 'sk' => 'Slovak', + 'sl' => 'Slovenian', + 'fi' => 'Suomi', + 'se' => 'Svenska', + 'th_TH' => 'Thai', + 'tr' => 'Turkish', + 'uk' => 'Ukrainian', + 'vn' => 'Vietnamese' +); + +$rcube_language_aliases = array( + 'ee' => 'et_EE', + 'bs' => 'bs_BA', + 'cn' => 'zh_CN', + 'de' => 'de_DE', + 'en' => 'en_US', + 'ga' => 'ga_IE', + 'nl' => 'nl_NL', + 'no' => 'nn_NO', + 'pt' => 'pt_PT', + 'th' => 'th_TH', + 'tw' => 'zh_TW' +); + +$rcube_charsets = array(); + +?> diff --git a/translator/messages.inc b/translator/messages.inc new file mode 100644 index 000000000..2745e860a --- /dev/null +++ b/translator/messages.inc @@ -0,0 +1,17 @@ +<?php + +/* + +-----------------------------------------------------------------------+ + | language/#lang/messages.inc | + | | + | Language file of the RoundCube Webmail client | + | Copyright (C) 2006, RoundQube Dev. - Switzerland | + | Licensed under the GNU GPL | + | | + +-----------------------------------------------------------------------+ + | Author: | + +-----------------------------------------------------------------------+ + +*/ + +$messages = array(); diff --git a/translator/robots.txt b/translator/robots.txt new file mode 100644 index 000000000..77470cb39 --- /dev/null +++ b/translator/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /
\ No newline at end of file diff --git a/translator/styles.css b/translator/styles.css new file mode 100644 index 000000000..58f7f032d --- /dev/null +++ b/translator/styles.css @@ -0,0 +1,85 @@ + +body { + background: #F6F6F6; + font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; + font-size: small; + color: #000000; + margin: 12px; +} + +fieldset { + border: 1px solid #bbb; + padding: 8px; +} + +#pageheader { + color: #BB0000; +} + +.console { + display: none; + color: #999; + margin-bottom: 0.5em; +} + +.translist thead td { + font-weight: bold; + padding: 2px 6px 2px 4px; +} + +.translist tbody td { + padding: 2px 6px 2px 4px; + border-bottom: 1px solid #ccc; +} + +.untranslated { + background: #EF9398; +} + +.key { + font-family: monospace; + font-size: x-small; +} + +.original { + color: black; +} + +#translations { + margin: 20px 0; +} + +#resultsbox { + +} + +#results { + font-family: monospace; + font-size: x-small; +} + + +/*****************/ + + +input, textarea +{ + font-size: 9pt; + font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; + padding: 1px; + padding-left: 3px; + padding-right: 3px; + background-color: #ffffff; + border: 1px solid #666666; +} + +input.button +{ + height: 20px; + color: #333333; + font-size: 12px; + padding-left: 8px; + padding-right: 8px; + background: url('button.gif') repeat-x #f0f0f0; + border: 1px solid #a4a4a4; +} |
