[Po4a-commits] "po4a/scripts po4aman-display-po, 1.7, 1.8 po4aman-display-po.1, 1.1, 1.2"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Sun Apr 16 22:09:35 UTC 2006


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

Modified Files:
	po4aman-display-po po4aman-display-po.1 
Log Message:
po4aman-display-po improvements. Thanks to Florentin Duneau.


Index: po4aman-display-po.1
===================================================================
RCS file: /cvsroot/po4a/po4a/scripts/po4aman-display-po.1,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- po4aman-display-po.1	8 Apr 2006 14:23:33 -0000	1.1
+++ po4aman-display-po.1	16 Apr 2006 22:09:33 -0000	1.2
@@ -12,8 +12,8 @@
 .IR PO4A_OPT ]
 
 .SH DESCRIPTION
-\fBpo4aman-display-po\fP can be used by a translator who want to check
-how the manpage being translated in a PO will be displayed.
+\fBpo4aman-display-po\fP can be used by a translator who wants to check
+how the man page being translated in a PO will be displayed.
 
 .SH OPTIONS
 .TP
@@ -22,10 +22,13 @@
 .TP
 .BI "\-m " MASTER_FILE
 The original man page.
+It can be the absolute or relative path to the original man page (gzipped
+or not), the name the man page or the name and section of the man page
+(using the man.section format).
 .br
 When the master document is not provided with the \fB\-m\fP option,
-\fBpo4aman-display-po\fP tries to find the original manpage on the
-user's based on the line reference of the first string in the PO.
+\fBpo4aman-display-po\fP tries to find the original man page
+based on the line reference of the first string in the PO.
 .TP
 .BI "\-o " PO4A_OPT
 Some options to pass to \fBpo4a-translate\fP.

Index: po4aman-display-po
===================================================================
RCS file: /cvsroot/po4a/po4a/scripts/po4aman-display-po,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- po4aman-display-po	16 Apr 2006 19:47:38 -0000	1.7
+++ po4aman-display-po	16 Apr 2006 22:09:33 -0000	1.8
@@ -46,30 +46,58 @@
   exit 1
 fi
 
+if [ ! -f $PO ]
+then
+  error "could not find po file: $PO"
+fi
+
 if [ -z "$MASTER" ]
 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)
+  MASTER=$(grep -m 1 "^#:" $PO | sed -e 's/^.* \(.*\):.*$/\1/')
+fi
+
+find_man()
+{
+  section=$1
+  man=$2
+  echo -n "Looking for manpage $file"
+  [ -n "$section" ] && echo " in section $section" || echo ""
+  MAN_NUMBER=`man --all --where --locale=C $section "$man" 2> /dev/null | wc -l`
+
+  if [ $MAN_NUMBER = "0" ]
+  then
+    return 1
+  elif [ $MAN_NUMBER != "1" ]; then
+    error "Too many possible manpages: $(man -aw -L C $section "$man"), you must specify the manpage or the section"
+  else
+    MASTER=`man --where --locale=C $section "$man"`
+  fi
+
+  return 0
+}
+
+if [ ! -f "$MASTER" ]
+then
+  echo "Can't find the master man page $MASTER"
+  file=$(basename "$MASTER")
+  MASTER=""
   section=""
-  echo Looking for manpage: $file
-  MASTER=$(man -w -L C $file)
-  if [ $? != "0" ]
+  if ! find_man "" "$file"
   then
-    section=$(echo $file | sed -ne 's/^.*\.\([1-9].*\)$/\1/p' -e 's/\..*//')
+    # Maybe $file contains a section
+    # (in the form of file.section.extension)
+    section=$(echo $file | sed -ne 's/^.*\.\([1-9].*\)$/\1/; s/\..*//; p')
     file=$(echo $file | sed -e 's/\.[1-9].*//')
-    echo looking for manpage $file in section $section
-    MASTER=$(man -w -L C $section $file)
-    if [ $? != "0" ]
+    if ! find_man "$section" "$file"
     then
+      # Maybe there is an extension at the end of the manpage (e.g. .man)
       file=$(echo $file | sed -e 's/\..*//')
-      echo looking for manpage $file in section $section
-      MASTER=$(man -w -L C $section $file)
-      if [ $? != "0" ]
+      if ! find_man "$section" "$file"
       then
-        echo No manpage found for $PO
-        echo you must provide the manpage with the -m option
+        echo No manpage found
+        echo You must provide the manpage with the -m option
         MASTER=""
       fi
     fi
@@ -92,10 +120,6 @@
 then
   error "could not find master file: $MASTER"
 fi
-if [ ! -e $PO ]
-then
-  error "could not find po file: $PO"
-fi
 
 
 if [ "${MASTER%.gz}" = "$MASTER" ]




More information about the Po4a-commits mailing list