Changeset 1345 in subversion
- Timestamp:
- Apr 30, 2008 9:16:56 AM (5 years ago)
- Location:
- trunk/translator
- Files:
-
- 5 edited
-
func.php (modified) (3 diffs)
-
index.php (modified) (7 diffs)
-
labels.inc (modified) (1 diff)
-
messages.inc (modified) (1 diff)
-
styles.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/translator/func.php
r1327 r1345 84 84 85 85 86 function build_localization($lang, $file) 87 { 88 global $orig_values, $edit_values; 89 90 $array = $file == "messages.inc" ? '$messages' : '$labels'; 91 $fpath = $lang != "_NEW_" ? update_from_svn($lang, $file) : 'nope'; 92 93 if (!strstr($fpath, 'http') && !is_file($fpath)) 94 $fpath = realpath("./$file"); 95 96 $out = ""; 97 if ($fpath && ($fp = fopen($fpath, 'r'))) 98 { 99 while (!feof($fp)) 100 { 101 $line = trim(fgets($fp)); 102 103 if (empty($line) && empty($out)) 104 continue; 105 106 $out .= str_replace('#lang', $lang, $line) . "\n"; 107 108 // reached begin of php array 109 if (strstr($line, $array)) 110 break; 111 } 112 } 113 else 114 { 115 $out .= '<?php' . "\n"; 116 $out .= $array . " = array();\n"; 117 } 118 119 foreach((array)$orig_values as $t_key => $t_value) 120 { 121 $t_value = get_input_value('t_'.$t_key); 122 if (empty($t_value) && isset($edit_values[$t_key])) 123 $t_value = $edit_values[$t_key]; 124 if (!empty($t_value)) 125 $out .= $array . "['$t_key'] = '" . addslashes($t_value) . "';\n"; 126 } 127 128 $out .= "\n?>\n"; 129 return $out; 130 } 131 132 86 133 // -------- EOF func --------// 87 134 … … 94 141 $translated = !empty($_REQUEST['trans']); 95 142 143 // read reference file 96 144 if ($file && $lang) 97 145 include(update_from_svn(ORIGINAL, $file)); … … 104 152 unset($labels, $messages); 105 153 154 // read current localization file 155 if (!empty($lang) && !empty($file)) 156 { 157 if ($lang != "_NEW_") 158 @include(update_from_svn($lang, $file)); 159 160 if (!empty($labels)) 161 $edit_values = $labels; 162 else if (!empty($messages)) 163 $edit_values = $messages; 164 else 165 $edit_values = array(); 166 167 unset($labels, $messages); 168 } 169 106 170 ?> -
trunk/translator/index.php
r1340 r1345 1 <?php header("Content-Type: text/html; charset=UTF-8"); ?> 1 <?php 2 3 ob_start(); 4 5 require_once 'func.php'; 6 7 if (isset($_POST["download"]) && $file && $lang) 8 { 9 ob_end_clean(); 10 11 header("Content-Type: text/plain; charset=UTF-8"); 12 header("Cache-Control: private"); 13 header("Content-Disposition: attachment; filename=\"{$file}\""); 14 15 echo build_localization($lang, $file); 16 exit; 17 } 18 else 19 header("Content-Type: text/html; charset=UTF-8"); 20 21 ob_end_clean(); 22 23 ?> 2 24 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3 25 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et"> … … 15 37 </div> 16 38 17 <?php include('func.php'); ?>18 19 39 <div id="bodycontent"> 20 40 21 <form method="post" action="<? =$_SERVER['PHP_SELF']?>">41 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 22 42 <fieldset> 23 43 <legend>What to translate</legend> … … 26 46 27 47 <select name="file"> 28 <option value="labels.inc"<? =($file=='labels.inc'?' selected':'')?>>labels.inc</option>29 <option value="messages.inc"<? =($file=='messages.inc'?' selected':'')?>>messages.inc</option>48 <option value="labels.inc"<?php echo ($file=='labels.inc'?' selected':''); ?>>labels.inc</option> 49 <option value="messages.inc"<?php echo ($file=='messages.inc'?' selected':''); ?>>messages.inc</option> 30 50 </select> 31 51 32 52 <div> 33 <input type="checkbox" name="trans" id="trans" value="1"<? =($translated?' checked':'')?> />53 <input type="checkbox" name="trans" id="trans" value="1"<?php echo ($translated?' checked':''); ?> /> 34 54 <label for="trans">Show translated texts</label> 35 55 </div> … … 40 60 41 61 <div id="translations"> 42 <form method="post" action="<? =$_SERVER['PHP_SELF']?>">62 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 43 63 <input type="hidden" name="save" value="1" /> 44 64 <?php … … 50 70 echo '<table border="0" cellspacing="0" class="translist" summary="">'; 51 71 echo '<thead><tr><td>Label</td><td>Original</td><td>Translation</td></tr></thead><tbody>'; 52 53 if ($lang != "_NEW_")54 @include(update_from_svn($lang, $file));55 56 if (!empty($labels))57 $edit_values = $labels;58 else if (!empty($messages))59 $edit_values = $messages;60 else61 $edit_values = array();62 72 63 73 $count = 0; … … 84 94 85 95 echo "</tbody></table>\n"; 86 echo '<p><input type="submit" class="button" name="translate" value="Create translation"/></p>'; 96 echo '<p><br /><input type="submit" class="button" name="translate" value="Create translation" />'; 97 echo '<span style="padding-left:1.5em"><input type="checkbox" name="download" value="1" checked="checked" /> Download directly</a></p>'; 98 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>'; 87 99 88 100 } … … 96 108 if (isset($_POST["save"]) && $file && $lang) 97 109 { 98 $array = $file == "messages.inc" ? '$messages' : '$labels';99 $fpath = $lang != "_NEW_" ? update_from_svn($lang, $file) : 'nope';100 101 if (!strstr($fpath, 'http') && !is_file($fpath))102 $fpath = realpath("./$file");103 104 110 echo '<div id="resultsbox">'."<h3>Localization file</h3>\n"; 105 111 echo '<form id="select_all" action="./"> 106 112 <textarea id="results" name="text_area" rows="'.min(30, count($orig_values)).'" cols="130">'; 107 108 if ($fpath && ($fp = fopen($fpath, 'r'))) 109 { 110 while (!feof($fp)) 111 { 112 $line = fgets($fp); 113 echo htmlspecialchars(str_replace('#lang', $lang, rtrim($line))) . "\n"; 114 if (strstr($line, $array)) 115 break; 116 } 117 } 118 else 119 { 120 echo "<?php\n"; 121 echo $array . " = array();\n"; 122 } 123 124 foreach($orig_values as $t_key => $t_value) 125 { 126 $t_value = get_input_value('t_'.$t_key); 127 if (empty($t_value) && isset($edit_values[$t_key])) 128 $t_value = $edit_values[$t_key]; 129 if (!empty($t_value)) 130 echo $array . "['$t_key'] = '" . addslashes(htmlspecialchars($t_value, ENT_COMPAT, 'UTF-8')) . "';\n"; 131 } 132 133 echo "\n?></textarea>\n"; 113 echo htmlspecialchars(build_localization($lang, $file), ENT_COMPAT, 'UTF-8'); 114 echo "</textarea>\n"; 134 115 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>'; 135 116 echo "\n</form></div>"; -
trunk/translator/labels.inc
r1276 r1345 6 6 | | 7 7 | Language file of the RoundCube Webmail client | 8 | Copyright (C) 200 6, RoundQube Dev. - Switzerland |8 | Copyright (C) 2008, RoundQube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | -
trunk/translator/messages.inc
r1276 r1345 6 6 | | 7 7 | Language file of the RoundCube Webmail client | 8 | Copyright (C) 200 6, RoundQube Dev. - Switzerland |8 | Copyright (C) 2008, RoundQube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | -
trunk/translator/styles.css
r1340 r1345 79 79 } 80 80 81 .hint { 82 color: #999; 83 } 84 81 85 #translations { 82 86 margin: 20px 0;
Note: See TracChangeset
for help on using the changeset viewer.
