3 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
5 textarea { width: 100% }
6 .no { background: #ffdddd; }
7 label { border-bottom: 1px solid #888; }
13 $FRIENDIKA_PATH = dirname(dirname(__FILE__));
17 $d = dir($FRIENDIKA_PATH."/view");
18 while (false !== ($entry = $d->read())) {
19 if (is_file($d->path."/".$entry."/strings.php")){
28 var $strings = Array();
31 function loadstrings($lang = NULL){
32 global $FRIENDIKA_PATH;
34 $path = $FRIENDIKA_PATH."/util/strings.php";
36 $path = $FRIENDIKA_PATH."/view/$lang/strings.php";
44 function savestrings($lang, $strings){
45 global $FRIENDIKA_PATH;
46 $path = $FRIENDIKA_PATH."/view/$lang/strings.php";
47 $f = fopen($path,"w");
48 fwrite($f, "<"); fwrite($f, "?php\n");
49 foreach($strings as $k=>$v){
50 $k=str_replace("'","\'", $k);
51 $k=str_replace("\\\\'","\'", $k);
52 $k=str_replace("\n","\\n", $k);
53 $k=str_replace("\r","\\r", $k);
54 $v=str_replace("'","\'", $v);
55 $v=str_replace("\\\\'","\'", $v);
56 $v=str_replace("\n","\\n", $v);
57 $v=str_replace("\r","\\r", $v);
59 fwrite( $f, '$a->strings[\''.$k.'\'] = \''. $v .'\';'."\n" );
60 #echo '$a->strings[\''.$k.'\'] = \''. $v .'\''."\n" ;
62 fwrite($f, "?"); fwrite($f, ">\n");
68 function hexstr($hexstr) {
69 $hexstr = str_replace(' ', '', $hexstr);
70 $hexstr = str_replace('\x', '', $hexstr);
71 $retstr = pack('H*', $hexstr);
75 function strhex($string) {
76 $hexstr = unpack('H*', $string);
77 return array_shift($hexstr);
81 echo "<h1>Translator</h1>";
82 echo "<small>Utility to translate <code>string.php</code> file.";
83 echo " Need write permission to language file you want to modify</small>";
84 echo "<p>Installed languages:";
85 foreach($LANGS as $l){
86 echo "<a href='?lang=$l'>$l</a>, ";
91 $strings['en'] = loadstrings();
93 if (isset($_GET['lang'])){
95 $lang = $_GET['lang'];
96 $strings[$lang] = loadstrings($lang);
98 $n1 = count($strings['en']);
99 $n2 = count($strings[$lang]);
102 echo "Translate en to $lang<br>";
103 //echo "Translated $n2 over $n1 strings<br>";
108 if (isset($_POST['save'])){
110 foreach ($_POST as $k=>$v){
111 if ($k!="save" && $k!="from"){
113 $strings[$lang][$k] = $v;
116 savestrings($lang, $strings[$lang]);
124 if (!isset($_POST['from'])){
127 $from = $_POST['from'];
128 if ($_POST['save']=="Next")
130 if ($_POST['save']=="Prev")
133 $count = count($strings['en']);
135 if ($from+$len>$count) $len=$count-$from;
136 $thestrings = array_slice($strings['en'], $from, $len, true);
140 echo "<form method='POST'>";
143 echo "<input type='submit' name='save' id='save' value='Prev'/>";
144 echo "<input type='submit' name='reload' id='reload' value='Reload'/>";
145 if ($from+$len<$count)
146 echo "<input type='submit' name='save' id='save' value='Next'/>";
148 foreach($thestrings as $k=>$v){
150 $translation = $strings[$lang][$k];
152 $v=str_replace("\n","\\n", $v);
153 $v=str_replace("\r","\\r", $v);
154 $translation=str_replace("\n","\\n", $translation);
155 $translation=str_replace("\r","\\r", $translation);
157 $istranslate = $translation != '' ? 'yes':'no';
158 echo "<dl class='$istranslate'>";
159 echo "<dt><pre><label for='$id'>".htmlspecialchars($v)."</label></pre></dt>";
160 echo "<dd><textarea id='$id' name='$id'>$translation</textarea></dd>";
165 echo "<input type='hidden' name='from' value='$from'/>";
168 echo "<input type='submit' name='save' id='save' value='Prev'/>";
169 echo "<input type='submit' name='reload' id='reload' value='Reload'/>";
170 if ($from+$len<$count)
171 echo "<input type='submit' name='save' id='save' value='Next'/>";