[Svn] r2178 - trunk/translator

trac at roundcube.net trac at roundcube.net
Thu Dec 18 19:04:51 CET 2008


Author: thomasb
Date: 2008-12-18 12:04:51 -0600 (Thu, 18 Dec 2008)
New Revision: 2178

Modified:
   trunk/translator/func.php
   trunk/translator/index.php
   trunk/translator/styles.css
Log:
Use update_from_svn() to get localization files for stats;
Store stats file in (writeable) localization folder;
Increase cache time to 12 hours;
Some style tweaks



Modified: trunk/translator/func.php
===================================================================
--- trunk/translator/func.php	2008-12-18 17:57:49 UTC (rev 2177)
+++ trunk/translator/func.php	2008-12-18 18:04:51 UTC (rev 2178)
@@ -42,7 +42,7 @@
 		$headers = true;
 		if ($fp && !$err && ($fl = @fopen(LANGDIR."$lang_prefix$file", 'w')))
 		{
-			// echo '<div class="console">Update from SVN: '.$lang_dir.$file.'</div>';
+			echo '<!-- Update from SVN: ' . $lang_dir.$file . "-->\n";
 			while (!feof($fp))
 			{
 				$line = fgets($fp, 4096);
@@ -130,12 +130,12 @@
 	return $out;
 }
 
-function count_lines($filename)
+function count_lines($lang, $file)
 {
 	$count = 0;
 	$lines = array();
 	
-	if(file_exists($filename))
+	if ($filename = update_from_svn($lang, $file))
 		$lines = file($filename);
 	
 	// count lines starting with $ ($labels/$messages)
@@ -146,17 +146,18 @@
 	return $count;
 }
 
-function localization_stats()
+function localization_stats($force = false)
 {
+	$cachefile = LANGDIR . 'langstats.txt';
 	// use saved file (cache)
-	if(file_exists('langstats.txt'))
-		if(filemtime('langstats.txt') + 60*60*2 > time())
-			return file_get_contents('langstats.txt');
+	if (!$force && file_exists($cachefile))
+		if (filemtime($cachefile) + 60*60*12 > time())
+			return file_get_contents($cachefile);
 
-	$us_count = count_lines(LANGDIR.'/'.ORIGINAL.'/'.LABELS);
-	$us_count += count_lines(LANGDIR.'/'.ORIGINAL.'/'.MESSAGES);
+	$us_count = count_lines(ORIGINAL, LABELS);
+	$us_count += count_lines(ORIGINAL, MESSAGES);
 
-	include(LANGDIR.'/index.inc');
+	include(LANGDIR . 'index.inc');
 	
 	$i = 0;
 	foreach ((array)$rcube_languages as $l_key => $l_value)
@@ -164,8 +165,8 @@
 		if ($l_key == ORIGINAL)
 			continue;
 
-		$count = count_lines(LANGDIR.'/'.$l_key.'/'.LABELS);
-		$count += count_lines(LANGDIR.'/'.$l_key.'/'.MESSAGES);
+		$count = count_lines($l_key, LABELS);
+		$count += count_lines($l_key, MESSAGES);
 		$percent = ($count * 100) / $us_count;
 		
 		$rows[] = sprintf("<tr><td class=\"lang%s\">%s</td><td class=\"percent%s\">%.1f %%</td></tr>\n",
@@ -184,7 +185,7 @@
 	$result .= '</td></tr></table>';
 	
 	// save to cache file
-	file_put_contents('langstats.txt', $result);
+	file_put_contents($cachefile, $result);
 	
 	return $result;
 }

Modified: trunk/translator/index.php
===================================================================
--- trunk/translator/index.php	2008-12-18 17:57:49 UTC (rev 2177)
+++ trunk/translator/index.php	2008-12-18 18:04:51 UTC (rev 2178)
@@ -115,10 +115,12 @@
 	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>';
 	echo "\n</form></div>";
 }
-else
+else if (empty($file))
+{
+	echo '<h4>Current completeness status</h4>';
+	echo '<div>'.localization_stats().'</div>';
+}
 
-	echo '<div align="center">'.localization_stats().'</div>';
-
 ?>
 </div>
 

Modified: trunk/translator/styles.css
===================================================================
--- trunk/translator/styles.css	2008-12-18 17:57:49 UTC (rev 2177)
+++ trunk/translator/styles.css	2008-12-18 18:04:51 UTC (rev 2178)
@@ -103,7 +103,7 @@
 table.langstats {
 	width: 300px;
 	border-collapse: collapse;
-	border: 1px #999 solid;
+	border: 1px #bbb solid;
 }
 
 td.lang {
@@ -119,7 +119,7 @@
 }
 
 td.zebra {
-	background-color: silver;
+	background-color: #eaeaea;
 }
 
 /*****************/

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list