1b97e4b0e6ad500651709b419d0fd3aa0245206d
Runa A. Sandvik translated man pages for th...

Runa A. Sandvik authored 13 years ago

manpages/po2man.sh   1) #!/bin/bash
manpages/po2man.sh   2) #
manpages/po2man.sh   3) # Author: Runa A. Sandvik, <runa.sandvik@gmail.com>
manpages/po2man.sh   4) # For The Tor Project, Inc.
manpages/po2man.sh   5) #
manpages/po2man.sh   6) # This is Free Software (GPLv3)
manpages/po2man.sh   7) # http://www.gnu.org/licenses/gpl-3.0.txt
manpages/po2man.sh   8) #
manpages/po2man.sh   9) # This script will convert translated po files back to manpages. Before
manpages/po2man.sh  10) # running the script, checkout the translation directory from
manpages/po2man.sh  11) # https://svn.torproject.org, and clone the tor repository from
manpages/po2man.sh  12) # git.torproject.org.
manpages/po2man.sh  13) #	
manpages/po2man.sh  14) 
manpages/po2man.sh  15) ### Start config ###
manpages/po2man.sh  16) 
manpages/po2man.sh  17) # Location of the translated manpages
manpages/po2man.sh  18) translated="$PWD"
manpages/po2man.sh  19) 
manpages/po2man.sh  20) # Location of the website directory
manpages/po2man.sh  21) wml="`dirname $translated`"
manpages/po2man.sh  22) 
manpages/po2man.sh  23) # Location of the English manpages. Assuming that the git clone of the
manpages/po2man.sh  24) # tor repository is relative to the website
manpages/po2man.sh  25) mandir="`dirname $wml`/tor/doc"
manpages/po2man.sh  26) 
manpages/po2man.sh  27) # Location of the po files. Assuming that the translation directory is
manpages/po2man.sh  28) # relative to the website
manpages/po2man.sh  29) podir="`dirname $wml`/translation/projects/manpages/po"
manpages/po2man.sh  30) 
manpages/po2man.sh  31) ### End config ###
manpages/po2man.sh  32) 
manpages/po2man.sh  33) # Find po files to convert
manpages/po2man.sh  34) po=`find $podir -type f -name \*.1.po`
manpages/po2man.sh  35) 
manpages/po2man.sh  36) # For every po found, create and/or update the translated manpage.
manpages/po2man.sh  37) for file in $po ; do
manpages/po2man.sh  38) 
Runa A. Sandvik updated po2wml and po2man

Runa A. Sandvik authored 13 years ago

manpages/po2man.sh  39) 	# Validate input and write results to a log file
Runa A. Sandvik updated script, updated tra...

Runa A. Sandvik authored 13 years ago

manpages/po2man.sh  40) 	validate_script="/home/runa/tor/translation/tools/validate.py"
manpages/po2man.sh  41) 	validate_log="/home/runa/tor/validate/manpages-validate.log"
Runa A. Sandvik updated po2wml and po2man

Runa A. Sandvik authored 13 years ago

manpages/po2man.sh  42) 	python "$validate_script" -i "$file" -l "$validate_log"
manpages/po2man.sh  43) 
Runa A. Sandvik translated man pages for th...

Runa A. Sandvik authored 13 years ago

manpages/po2man.sh  44) 	# Get the basename of the file we are dealing with
manpages/po2man.sh  45) 	pofile=`basename $file`
manpages/po2man.sh  46) 
manpages/po2man.sh  47) 	# Strip the file for its original extension and add .txt
manpages/po2man.sh  48) 	manfile="${pofile%.*}.txt"
manpages/po2man.sh  49) 
manpages/po2man.sh  50) 	# Figure out which language we are dealing with.
manpages/po2man.sh  51) 	lang=`dirname $file | sed "s#$podir/##"`
manpages/po2man.sh  52) 
manpages/po2man.sh  53) 	# The translated document is written if 80% or more of the po
manpages/po2man.sh  54) 	# file has been translated. Also, po4a-translate will only write
manpages/po2man.sh  55) 	# the translated document if 80% or more has been translated.
manpages/po2man.sh  56) 	# However, it will delete the translated txt if less than 80%
manpages/po2man.sh  57) 	# has been translated. To avoid having our current, translated
manpages/po2man.sh  58) 	# txt files deleted, convert the po to a temp txt first. If this
manpages/po2man.sh  59) 	# file was actually written, rename it to txt.
manpages/po2man.sh  60) 
manpages/po2man.sh  61) 	# Convert translated po files back to manpages.
manpages/po2man.sh  62) 	function convert {
manpages/po2man.sh  63) 		po4a-translate -f text -m "$mandir/$manfile" -p "$file"  -l "$translated/$lang/tmp-$manfile" --master-charset utf-8 -L utf-8
manpages/po2man.sh  64) 
manpages/po2man.sh  65) 		# Check to see if the file was written. If yes, rename
manpages/po2man.sh  66) 		# it.
manpages/po2man.sh  67) 		if [ -e "$translated/$lang/tmp-$manfile" ]
manpages/po2man.sh  68) 		then
manpages/po2man.sh  69) 			mv "$translated/$lang/tmp-$manfile" "$translated/$lang/$manfile"
manpages/po2man.sh  70) 
manpages/po2man.sh  71) 			# If tor.1.po has been translated, we need to
manpages/po2man.sh  72) 			# create tor-manual-dev.wml in the correct
manpages/po2man.sh  73) 			# language directory.
manpages/po2man.sh  74) 			if [ $manfile = "tor.1.txt" ]
manpages/po2man.sh  75) 			then
manpages/po2man.sh  76) 				if [ ! -e "$wml/docs/$lang/tor-manual-dev.wml" ]
manpages/po2man.sh  77) 				then
manpages/po2man.sh  78) 
manpages/po2man.sh  79) 					if [ ! -d "$wml/docs/$lang/" ]
manpages/po2man.sh  80) 					then
manpages/po2man.sh  81) 						mkdir "$wml/docs/$lang/"
manpages/po2man.sh  82) 					fi
manpages/po2man.sh  83) 
manpages/po2man.sh  84) 					# Copy template file for
manpages/po2man.sh  85) 					# tor-manual-dev.wml, and
manpages/po2man.sh  86) 					# replace "lang" with the
manpages/po2man.sh  87) 					# correct name of the language
manpages/po2man.sh  88) 					# directory.
Runa A. Sandvik cleaning up the manpage dir...

Runa A. Sandvik authored 13 years ago

manpages/po2man.sh  89) 					cp "$translated/en/tor-manual-dev.wml" "$wml/docs/$lang"