From f7fb0d5f560f11abc1738837e235853668ad4c6e Mon Sep 17 00:00:00 2001 From: thomasb Date: Wed, 30 Apr 2008 13:16:56 +0000 Subject: Remove short php tags + add option to download the localization file git-svn-id: https://svn.roundcube.net/trunk@1345 208e9e7b-5314-0410-a742-e7e81cd9613c --- translator/func.php | 64 +++++++++++++++++++++++++++++++++++++ translator/index.php | 85 +++++++++++++++++++------------------------------ translator/labels.inc | 2 +- translator/messages.inc | 2 +- translator/styles.css | 4 +++ 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 .= ' $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 @@ - + @@ -14,23 +36,21 @@ - -
-
+
What to translate
- /> + />
@@ -39,7 +59,7 @@
-
+ '; echo 'LabelOriginalTranslation'; - 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 'No new texts to translate'; echo "\n"; - echo '

'; + echo '


'; + echo ' Download directly

'; + echo '

Save the localization file and post it to the dev-mailing list

'; } @@ -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 '
'."

Localization file

\n"; echo ' \n"; + echo htmlspecialchars(build_localization($lang, $file), ENT_COMPAT, 'UTF-8'); + echo "\n"; echo '

'; echo "\n
"; } 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; } -- cgit v1.2.3