[Po4a-commits] "po4a/scripts po4aman-display-po,1.1,1.2"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Fri Apr 7 22:27:33 UTC 2006


Update of /cvsroot/po4a/po4a/scripts
In directory haydn:/tmp/cvs-serv17578/scripts

Modified Files:
	po4aman-display-po 
Log Message:
Try to detect the original man page according to the references in the PO.


Index: po4aman-display-po
===================================================================
RCS file: /cvsroot/po4a/po4a/scripts/po4aman-display-po,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- po4aman-display-po	7 Apr 2006 22:21:42 -0000	1.1
+++ po4aman-display-po	7 Apr 2006 22:27:30 -0000	1.2
@@ -1,9 +1,14 @@
 #!/bin/sh
+#
+# po4aman-display-po permits to see how a manpage translated with po4a
+# will be displayed, without needing to uncompress the original manpage
+# and call po4a-translate.
+#
 
 OPTIONS="";
 
 function usage() {
-  echo "Usage: $0 -m MASTER_FILE -p PO_FILE [-o PO4A_OPT]";
+  echo "Usage: $0 -p PO_FILE [-m MASTER_FILE] [-o PO4A_OPT]";
   return 0;
 }
 
@@ -30,6 +35,40 @@
   esac
 done
 
+if [ -z "$MASTER" ] && [ -n "$PO" ]
+then
+  echo "No manpage specified."
+  echo "Trying to find the manpage according to a line reference in the PO."
+  file=$(grep -m 1 "^#:" $PO | sed -e 's/^.* \(.*\):.*$/\1/')
+  file=$(basename $file)
+  ext=""
+  echo Looking for manpage: $file
+  MASTER=$(man -w $file)
+  if [ $? != "0" ]
+  then
+    ext=$(echo $file | sed -e 's/^.*\.\([1-9].*\)$/\1/' -e 's/\..*//')
+    file=$(echo $file | sed -e 's/\.[1-9].*//')
+    echo looking for manpage $file in section $ext
+    MASTER=$(man -w $ext $file)
+    if [ $? != "0" ]
+    then
+      file=$(echo $file | sed -e 's/\..*//')
+      echo looking for manpage $file in section $ext
+      MASTER=$(man -w $ext $file)
+      if [ $? != "0" ]
+      then
+        echo No manpage found for $PO
+        echo you must provide the manpage with the -m option
+        MASTER=""
+      fi
+    fi
+  fi
+  if [ -n "$MASTER" ]
+  then
+    echo Using: $MASTER as the original manpage
+  fi
+fi
+
 # checking mandatory options
 if [ -z $MASTER ];
 then




More information about the Po4a-commits mailing list