hholzgra Wed Apr 3 16:04:09 2002 EDT
Added files:
/phpdoc/scripts file-entities.php
Modified files:
/phpdoc configure.in
Log:
faster generation of file entities for translation support if php available
(no big performance gain yet, but doing this with 3000+ splitted file
justifies using php instead of shell)
Index: phpdoc/configure.in
diff -u phpdoc/configure.in:1.144 phpdoc/configure.in:1.145
--- phpdoc/configure.in:1.144 Mon Mar 11 19:57:46 2002
+++ phpdoc/configure.in Wed Apr 3 16:04:06 2002
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.144 2002/03/12 00:57:46 torben Exp $
+dnl $Id: configure.in,v 1.145 2002/04/03 21:04:06 hholzgra Exp $
dnl autoconf initialisation
AC_INIT()
@@ -733,6 +733,9 @@
rm -f entities/chapters.ent
DEPEND_FILES=""
echo "<!-- DON'T TOUCH - AUTOGENERATED BY ./configure -->" > entities/chapters.ent
+
+dnl {{{ ZendAPI entities
+
if test -d "$ZENDAPI"; then
echo >> entities/chapters.ent
echo "<!-- begin ZendAPI integration -->" >> entities/chapters.ent
@@ -749,6 +752,11 @@
echo >> entities/chapters.ent
echo " Zend part not found"
fi
+
+dnl }}}
+
+dnl {{{ .CHM entities
+
if test "$CHMENABLED" = "yes"; then
echo "<!-- chmonly pages inclusion enabled -->" >> entities/chapters.ent
echo "<!ENTITY chmonly SYSTEM 'chmonly.xml'>" >> entities/chapters.ent
@@ -760,6 +768,11 @@
echo >> entities/chapters.ent
echo " CHM inclusion disabled"
fi
+
+dnl }}}
+
+dnl {{{ install already splitted?
+
if test -f "$srcdir/$LANGDIR/chapters/install.xml"; then
echo "<!-- old install.xml found in language dir -->" >> entities/chapters.ent
echo "<!ENTITY chapters.install SYSTEM '$srcdir/$LANGDIR/chapters/install.xml'>" >>
entities/chapters.ent
@@ -771,22 +784,37 @@
echo >> entities/chapters.ent
echo " Using the install part from installpart.xml"
fi
+
+dnl }}}
+
echo "<!-- Separated list of predefined constants. -->" >> entities/chapters.ent
echo "<!ENTITY appendices.reserved.constants SYSTEM 'reserved.constants.xml'>" >>
entities/chapters.ent
echo >> entities/chapters.ent
-for file in `find $srcdir/en -name "*.xml" | sed -e"s%^$srcdir\/en\/%%g" | sort`
-do
- name=`echo $file | sed -e"s/\//./g" -e"s/.xml$//g" -e "s/_/-/g"`
- if test -f $srcdir/$LANGDIR/$file
- then
- file=$srcdir/$LANGDIR/$file
- else
- file=$srcdir/en/$file
- echo " Untranslated $file (`wc -l <$file | tr -d ' '` lines)"
- fi
- DEPEND_FILES="$DEPEND_FILES $file"
- echo "<!ENTITY $name SYSTEM \"$file\">" >> entities/chapters.ent
-done
+
+dnl {{{ check configured language files against english tree
+
+if test $PHP != "no"
+then
+ $PHP -q $srcdir/scripts/file-entities.php $srcdir $LANGDIR >>
+entities/chapters.ent
+else
+ for file in `find $srcdir/en -name "*.xml" | sed -e"s%^$srcdir\/en\/%%g" | sort`
+ do
+ name=`echo $file | sed -e"s/\//./g" -e"s/.xml$//g" -e "s/_/-/g"`
+ if test -f $srcdir/$LANGDIR/$file
+ then
+ file=$srcdir/$LANGDIR/$file
+ else
+ file=$srcdir/en/$file
+ echo " Untranslated $file (`wc -l <$file | tr -d ' '` lines)"
+ fi
+ DEPEND_FILES="$DEPEND_FILES $file"
+ echo "<!ENTITY $name SYSTEM \"$file\">" >> entities/chapters.ent
+ done
+fi
+
+dnl }}}
+
+
echo "<!ENTITY global.function-index SYSTEM \"./funcindex.xml\">" >>
entities/chapters.ent
chmod a-w entities/chapters.ent
Index: phpdoc/scripts/file-entities.php
+++ phpdoc/scripts/file-entities.php
<?php
/*
Scan directory tree against original language tree and define
file entities for translated files where present with original
untranslated files as fallback where no translated version
exists
*/
ob_end_clean();
ob_implicit_flush();
$base_dir = abs_path($argv[1]);
if(php_sapi_name!="cli") $base_dir=ereg_replace("/scripts$","",$base_dir);
$orig_dir = $base_dir."/en";
$trans_dir = $base_dir."/".$argv[2];
process($orig_dir,$trans_dir,$orig_dir);
function abs_path($path) {
if($path{0} == '/') return $path;
$absdirs = explode("/",getcwd());
$dirs = explode("/",$path);
foreach($dirs as $dir) {
if(empty($dir) or $dir==".") continue;
else if($dir=="..") array_pop($absdirs);
else array_push($absdirs,$dir);
}
return join("/",$absdirs);
}
function process($work_dir, $trans_dir, $orig_dir) {
$trans_path = str_replace($orig_dir,$trans_dir,$work_dir);
$dh = opendir($work_dir);
if(!$dh) return false;
while(false !== ($file = readdir($dh))) {
if($file=="."||$file==".."||$file=="CVS") continue;
if(is_dir($work_dir."/".$file)) process($work_dir."/".$file,
$trans_dir, $orig_dir);
if(ereg("\\.xml$",$file)) {
$name =
str_replace("$orig_dir/","",$work_dir."/".ereg_replace("\\.xml$","",$file));
$name = str_replace("/",".",$name);
$name = str_replace("_","-",$name);
if(file_exists("$trans_path/$file")) {
$path= "$trans_path/$file";
} else {
$path= "$work_dir/$file";
}
echo sprintf("<!ENTITY %-40s SYSTEM '$path'>\n",$name);
}
}
closedir($dh);
}
?>