summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--translator/func.php64
-rw-r--r--translator/index.php85
-rw-r--r--translator/labels.inc2
-rw-r--r--translator/messages.inc2
-rw-r--r--translator/styles.css4
5 files changed, 103 insertions, 54 deletions
diff --git a/translator/func.php b/translator/func.php
index 3e62a72c7..fdaf2bcdf 100644
--- a/translator/func.php
+++ b/translator/func.php
@@ -83,6 +83,53 @@ function lang_selection($lang)
}
+function build_localization($lang, $file)
+{
+ global $orig_values, $edit_values;
+
+ $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");
+
+ $out = "";
+ if ($fpath && ($fp = fopen($fpath, 'r')))
+ {
+ while (!feof($fp))
+ {
+ $line = trim(fgets($fp));
+
+ if (empty($line) && empty($out))
+ continue;
+
+ $out .= str_replace('#lang', $lang, $line) . "\n";
+
+ // reached begin of php array
+ if (strstr($line, $array))
+ break;
+ }
+ }
+ else
+ {
+ $out .= '<?php' . "\n";
+ $out .= $array . " = array();\n";
+ }
+
+ foreach((array)$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))
+ $out .= $array . "['$t_key'] = '" . addslashes($t_value) . "';\n";
+ }
+
+ $out .= "\n?>\n";
+ return $out;
+}
+
+
// -------- EOF func --------//
$header = array();
@@ -93,6 +140,7 @@ $file = get_input_value('file');
$lang = get_input_value('lang');
$translated = !empty($_REQUEST['trans']);
+// read reference file
if ($file && $lang)
include(update_from_svn(ORIGINAL, $file));
@@ -103,4 +151,20 @@ else if ($file == 'messages.inc' && $messages)
unset($labels, $messages);
+// read current localization file
+if (!empty($lang) && !empty($file))
+{
+ 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();
+
+ unset($labels, $messages);
+}
+
?> \ No newline at end of file
diff --git a/translator/index.php b/translator/index.php
index 5caaf5363..807159e30 100644
--- a/translator/index.php
+++ b/translator/index.php
@@ -1,4 +1,26 @@
-<?php header("Content-Type: text/html; charset=UTF-8"); ?>
+<?php
+
+ob_start();
+
+require_once 'func.php';
+
+if (isset($_POST["download"]) && $file && $lang)
+{
+ ob_end_clean();
+
+ header("Content-Type: text/plain; charset=UTF-8");
+ header("Cache-Control: private");
+ header("Content-Disposition: attachment; filename=\"{$file}\"");
+
+ echo build_localization($lang, $file);
+ exit;
+}
+else
+ header("Content-Type: text/html; charset=UTF-8");
+
+ob_end_clean();
+
+?>
<!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>
@@ -14,23 +36,21 @@
<h2 id="pageheader">RoundCube (Live) Translator</h2>
</div>
-<?php include('func.php'); ?>
-
<div id="bodycontent">
-<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
+<form method="post" action="<?php echo $_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>
+ <option value="labels.inc"<?php echo ($file=='labels.inc'?' selected':''); ?>>labels.inc</option>
+ <option value="messages.inc"<?php echo ($file=='messages.inc'?' selected':''); ?>>messages.inc</option>
</select>
<div>
-<input type="checkbox" name="trans" id="trans" value="1"<?=($translated?' checked':'')?> />
+<input type="checkbox" name="trans" id="trans" value="1"<?php echo ($translated?' checked':''); ?> />
<label for="trans">Show translated texts</label>
</div>
@@ -39,7 +59,7 @@
</form>
<div id="translations">
-<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="save" value="1" />
<?php
@@ -50,16 +70,6 @@ if (!empty($lang) && !empty($file))
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)
{
@@ -83,7 +93,9 @@ if (!empty($lang) && !empty($file))
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>';
+ echo '<p><br /><input type="submit" class="button" name="translate" value="Create translation" />';
+ echo '<span style="padding-left:1.5em"><input type="checkbox" name="download" value="1" checked="checked" />&nbsp;Download directly</a></p>';
+ 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>';
}
@@ -95,42 +107,11 @@ if (!empty($lang) && !empty($file))
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 "&lt;?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?&gt;</textarea>\n";
+ echo htmlspecialchars(build_localization($lang, $file), ENT_COMPAT, 'UTF-8');
+ echo "</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>";
}
diff --git a/translator/labels.inc b/translator/labels.inc
index b4b76e91f..a6aad5658 100644
--- a/translator/labels.inc
+++ b/translator/labels.inc
@@ -5,7 +5,7 @@
| language/#lang/labels.inc |
| |
| Language file of the RoundCube Webmail client |
- | Copyright (C) 2006, RoundQube Dev. - Switzerland |
+ | Copyright (C) 2008, RoundQube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
+-----------------------------------------------------------------------+
diff --git a/translator/messages.inc b/translator/messages.inc
index 2745e860a..4c5b5ec12 100644
--- a/translator/messages.inc
+++ b/translator/messages.inc
@@ -5,7 +5,7 @@
| language/#lang/messages.inc |
| |
| Language file of the RoundCube Webmail client |
- | Copyright (C) 2006, RoundQube Dev. - Switzerland |
+ | Copyright (C) 2008, RoundQube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
+-----------------------------------------------------------------------+
diff --git a/translator/styles.css b/translator/styles.css
index 596026954..0e02c05ab 100644
--- a/translator/styles.css
+++ b/translator/styles.css
@@ -78,6 +78,10 @@ fieldset {
color: black;
}
+.hint {
+ color: #999;
+}
+
#translations {
margin: 20px 0;
}