source: subversion/trunk/translator/index.php @ 1340

Last change on this file since 1340 was 1340, checked in by thomasb, 5 years ago

Add styled header to translator page

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date Revision
File size: 4.3 KB
Line 
1<?php header("Content-Type: text/html; charset=UTF-8"); ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et">
4<head>
5<title>RoundCube Translator</title>
6<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7<link rel="stylesheet" href="styles.css" type="text/css" media="screen" />
8</head>
9<body>
10
11<div id="banner">
12  <div class="banner-logo"><a href="http://roundcube.net"><img src="images/banner_logo.gif" width="200" height="56" border="0" alt="RoundCube Webmal Project" /></a></div>
13  <div class="banner-right"><img src="images/banner_right.gif" width="10" height="56" alt="" /></div>
14  <h2 id="pageheader">RoundCube (Live) Translator</h2>
15</div>
16
17<?php include('func.php'); ?>
18
19<div id="bodycontent">
20
21<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
22<fieldset>
23<legend>What to translate</legend>
24
25<?php echo lang_selection($lang); ?>
26
27<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>
30</select>
31
32<div>
33<input type="checkbox" name="trans" id="trans" value="1"<?=($translated?' checked':'')?> />
34<label for="trans">Show translated texts</label>
35</div>
36
37<p><input type="submit" class="button" value="Select" /></p>
38</fieldset>
39</form>
40
41<div id="translations">
42<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
43<input type="hidden" name="save" value="1" />
44<?php
45
46if (!empty($lang) && !empty($file))
47{
48        echo '<input type="hidden" name="lang" value="'.$lang.'" /><input type="hidden" name="file" value="'.$file.'" />';
49        echo '<input type="hidden" name="trans" value="'.($translated?'1':'').'" />';
50        echo '<table border="0" cellspacing="0" class="translist" summary="">';
51        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        else
61                $edit_values = array();
62       
63        $count = 0;
64        foreach($orig_values as $t_key => $t_value)
65        {
66                // skip translated lines
67                if(!$translated && !empty($edit_values[$t_key]))
68                        continue;
69
70                if ($post_value = get_input_value('t_'.$t_key))
71                        $edit_values[$t_key] = $post_value;
72
73                echo '<tr class="'.(empty($edit_values[$t_key]) ? 'untranslated' : '')."\">\n";
74                echo '<td class="key">'.htmlspecialchars($t_key).'</td>';
75                echo '<td class="original">'.htmlspecialchars($t_value).'</td>';
76                echo '<td><input name="t_'.$t_key.'" value="'.(!empty($edit_values[$t_key]) ? htmlspecialchars($edit_values[$t_key]) : "").'" size="60" />';
77                echo "</td>\n</tr>\n";
78               
79                $count++;
80        }
81       
82        if (!$count)
83                echo '<tr><td colspan="3"><em>No new texts to translate</em></td></tr>';
84       
85        echo "</tbody></table>\n";
86        echo '<p><input type="submit" class="button" name="translate" value="Create translation"/></p>';
87
88}
89
90?>
91</form>
92</div>
93
94<?php
95
96if (isset($_POST["save"]) && $file && $lang)
97{
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        echo '<div id="resultsbox">'."<h3>Localization file</h3>\n";
105        echo '<form id="select_all" action="./">
106        <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 "&lt;?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?&gt;</textarea>\n";
134        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        echo "\n</form></div>";
136}
137
138?>
139</div>
140
141</body>
142</html>
Note: See TracBrowser for help on using the repository browser.