SVN Commit by dpage: r4946 - in trunk/www: . include translation - Mailing list pgadmin-hackers

From svn@pgadmin.org
Subject SVN Commit by dpage: r4946 - in trunk/www: . include translation
Date
Msg-id 200601201428.k0KES9Xd002903@developer.pgadmin.org
Whole thread Raw
List pgadmin-hackers
Author: dpage
Date: 2006-01-20 14:28:09 +0000 (Fri, 20 Jan 2006)
New Revision: 4946

Added:
   trunk/www/translation/update.php
Removed:
   trunk/www/cache/
Modified:
   trunk/www/README.txt
   trunk/www/include/po_status.php
   trunk/www/translation/status.php
Log:
Move the translation cache to /tmp.


Modified: trunk/www/README.txt
===================================================================
--- trunk/www/README.txt    2006-01-20 13:52:20 UTC (rev 4945)
+++ trunk/www/README.txt    2006-01-20 14:28:09 UTC (rev 4946)
@@ -119,7 +119,7 @@

 # Run the translation cache update script:

-32 * * * * /usr/bin/wget -q -O /tmp/update.txt http://www.pgadmin.org/cache/update.php
+32 * * * * /usr/bin/wget -q -O /tmp/update.txt http://www.pgadmin.org/translation/update.php

 # Update the snapshots tree:


Modified: trunk/www/include/po_status.php
===================================================================
--- trunk/www/include/po_status.php    2006-01-20 13:52:20 UTC (rev 4945)
+++ trunk/www/include/po_status.php    2006-01-20 14:28:09 UTC (rev 4946)
@@ -299,67 +299,52 @@
   }

   function getStatistics ($_po_file_path) {
-      $_pathinfo = pathinfo($_po_file_path);
+    $_pathinfo = pathinfo($_po_file_path);
     $_dir      = $_pathinfo["dirname"];

     $_command = "cd $_dir; export LANGUAGE=en_US; /usr/bin/msgfmt --statistics $_po_file_path 2>&1";
     $_command_result = shell_exec ($_command);

-    // echo $_command_result."<br>";
-
-        $_po_stat = array();
+    $_po_stat = array();
     $_po_stat = explode(",", $_command_result);
-        $_size = count ($_po_stat);
+    $_size = count ($_po_stat);

     $_result = array();

     if ($_size>0) {
-        for ($_count=0; $_count < $_size; $_count++) {
-        reset($_po_stat);
-        if (preg_match ("/(\d+) translated/", trim($_po_stat[$_count]), $_match)) {
-                    $_result['translated'] = (int) $_match[1];
-        }
+        $_result['translated']=0;
+        $_result['untranslated']=0;
+        $_result['fuzzy']=0;

-        if (preg_match ("/(\d+) untranslated/", $_po_stat[$_count], $_match)) {
-                    $_result['untranslated'] = (int) $_match[1];
-        }

-        if (preg_match ("/(\d+) fuzzy/", trim($_po_stat[$_count]), $_match)) {
-                    $_result['fuzzy'] = (int) $_match[1];
-        }
-                //echo $_count.trim($_po_stat[$_count])."FIN<br>";
-            }
+        for ($_count=0; $_count < $_size; $_count++) {
+            reset($_po_stat);
+            if (preg_match ("/(\d+) translated/", trim($_po_stat[$_count]), $_match))
+                $_result['translated'] = (int) $_match[1];

-            if (!$_result['translated']) {
-                $_result['translated']=0;
-      }
+            if (preg_match ("/(\d+) untranslated/", $_po_stat[$_count], $_match))
+                $_result['untranslated'] = (int) $_match[1];

-      if (!$_result['untranslated']) {
-                $_result['untranslated']=0;
-      }
+            if (preg_match ("/(\d+) fuzzy/", trim($_po_stat[$_count]), $_match))
+                $_result['fuzzy'] = (int) $_match[1];
+        }

-      if (!$_result['fuzzy']) {
-                $_result['fuzzy']=0;
-      }
+        $_result['total'] = $_result['translated']+$_result['untranslated']+$_result['fuzzy'];

-      $_result['total'] = $_result['translated']+$_result['untranslated']+$_result['fuzzy'];
+        if ($_result['total'] > 0)
+            $_result['status'] =  round ($_result['translated']/$_result['total'], 2) * 100;
+        else
+            $_result['status'] = 0;

-      if ($_result['total'] > 0) {
-          $_result['status'] =  round ($_result['translated']/$_result['total'], 2) * 100;
-      } else {
-                $_result['status'] = 0;
-      }
+        if (($_result['status'] == 100) && ($_result['total'] != $_result['translated']))
+            $_result['status'] = 99;

-      if (($_result['status'] == 100) && ($_result['total'] != $_result['translated'])) {
-                $_result['status'] = 99;
-      }
+        return $_result;

-
-      return $_result;
     } else {
         $this_error = "Error: no statistics available for $_po_file_path";
-      return false;
-        }
+        return false;
+    }
   }
 }


Modified: trunk/www/translation/status.php
===================================================================
--- trunk/www/translation/status.php    2006-01-20 13:52:20 UTC (rev 4945)
+++ trunk/www/translation/status.php    2006-01-20 14:28:09 UTC (rev 4946)
@@ -13,8 +13,8 @@
 $outofdate->setWebRoot($_SERVER["DOCUMENT_ROOT"]);
 $outofdate->setSvnRoot($_SERVER["DOCUMENT_ROOT"]."/svnrepo/pgadmin3");

-$cache_translated = "../cache/cache_translated.txt";
-$cache_outofdate  = "../cache/cache_outofdate.txt";
+$cache_translated = "/tmp/pgadmin_translated_cache.txt";
+$cache_outofdate  = "/tmp/pgadmin_outofdate_cache.txt";

 $translated->_cache_load($cache_translated);
 $outofdate->_cache_load($cache_outofdate);

Added: trunk/www/translation/update.php
===================================================================
--- trunk/www/translation/update.php    2006-01-20 13:52:20 UTC (rev 4945)
+++ trunk/www/translation/update.php    2006-01-20 14:28:09 UTC (rev 4946)
@@ -0,0 +1,32 @@
+<?php
+
+include $GLOBALS["_SERVER"]["DOCUMENT_ROOT"] . "/include/po_status.php";
+
+$translated = new po_status();
+$outofdate = new po_status();
+
+$translated->setWebRoot($_SERVER["DOCUMENT_ROOT"]);
+$translated->setSvnRoot($_SERVER["DOCUMENT_ROOT"]."/svnrepo/pgadmin3");
+
+$outofdate->setWebRoot($_SERVER["DOCUMENT_ROOT"]);
+$outofdate->setSvnRoot($_SERVER["DOCUMENT_ROOT"]."/svnrepo/pgadmin3");
+
+$_cache_translated = "/tmp/pgadmin_translated_cache.txt";
+$_cache_outofdate = "/tmp/pgadmin_outofdate_cache.txt";
+
+include "config.php";
+
+$translated->_cache_save($_cache_translated);
+$outofdate->_cache_save($_cache_outofdate);
+
+?>
+<html>
+<head>
+<title>Cache update</title>
+</head>
+<body>
+<h1>Cache update</h1>
+<p>The translation statistics cache has been updated.</p>
+<p>Click <a href="status.php">here</a> to view the status page.</p>
+</body>
+</html>


pgadmin-hackers by date:

Previous
From: Andreas Pflug
Date:
Subject: Re: SVN Commit by dpage: r4943 - trunk/www
Next
From: "Renaud Fortier"
Date:
Subject: French translation - translation française