diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2008-04-30 13:16:56 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2008-04-30 13:16:56 +0000 |
| commit | f7fb0d5f560f11abc1738837e235853668ad4c6e (patch) | |
| tree | d639b282a8f29212a54fd1f9f477c7b309907274 /translator/func.php | |
| parent | a1fc1907825607e103b8706d6d05bf8f29b1e8e2 (diff) | |
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
Diffstat (limited to 'translator/func.php')
| -rw-r--r-- | translator/func.php | 64 |
1 files changed, 64 insertions, 0 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 |
