Aller au contenu

Auto-éditer un wikilivre/Annexer (Version internationalisée)/htmlman.sh

Un livre de Wikilivres.
#!/bin/bash
#H File: htmlman.sh
#H syntax: htmlman.sh <manual>
#H Example: htmlman.sh annex
VERSION=211122
#O If first param is empty print version and syntax
    if test -z $1
    then 
      echo "htmlman.sh version $VERSION" 
      echo "Usage: htmlman <manual> or ./htmlman.sh <manual>"
      exit -1
    fi
#O Include install variables
    pwd > pwd.txt
    if cat pwd.txt | grep ~/Annexer
	then Workdir=~/Annexer
	elif cat pwd.txt | grep ~/Add_appendix
    then Workdir=~/Add_appendix
	else echo "Workind directory not found"
	  exit -1
	fi
    rm pwd.txt
#O Download global variables
    source $Workdir/vars/installdir.var
    if test -z $Mandir
	then Mandir=$Installdir/man
	fi
	if test -z $Sbindir
	then Sbindir=$Installdir/sbin
	fi
    echo "Manuals directories = $Mandir"
    echo "Sbindir = $Sbindir"

#O find lang
#es
    if echo $LANG | grep es
	then 
	  Mylang=es
	  echo "Mi idioma retenido es '$Mylang' "
      echo "Puedes escribir 'alias htmlman=\"$Sbindir/htmlman\"' en una consola "  
#fr	  
    elif echo $LANG | grep fr
	then Mylang=fr
	  echo "Ma langue retenue est '$Mylang' "
	  echo "Vous pouvez taper 'alias htmlman=\"$Sbindir/htmlman\"' dans une console"
#en
    else
      if echo $LANG | grep en
      then Mylang=en
        echo "My retained language is '$Mylang' "
	    echo "You can type 'alias htmlman=\"$Sbindir/htmlman\"' in a terminal"
      fi
    fi
#O If manual exist in Mylang
    if test -e $Mandir/$Mylang/man1/$1.html
	then 
	  echo "$Mandir/$Mylang/man1/$1.html exist"
	  xdg-open $Mandir/$Mylang/man1/$1.html&
	elif test -e $Mandir/man1/$1.html
	then
	  echo "$Mandir/man1/$1.html exist"
	  xdg-open $Mandir/man1/$1.html&
	else
	  echo "$1.html is not found in user man pages. Attempt in the general manual"
      # Version navigateur
	  man2html /usr/share/man/man1/$1.1.gz > $1.html
      xdg-open $1.html&
      sleep 2
      rm $1.html
	fi
#O End of htmlman