4ec2ccb84c4276c4a12ddf78c00525082d8c8bc5
Runa A. Sandvik translated man pages for th...

Runa A. Sandvik authored 13 years ago

1) #!/bin/bash
2) #
3) # Author: Runa A. Sandvik, <runa.sandvik@gmail.com>
4) # For The Tor Project, Inc.
5) #
6) # This is Free Software (GPLv3)
7) # http://www.gnu.org/licenses/gpl-3.0.txt
8) #
9) # This script will convert translated po files back to manpages. Before
10) # running the script, checkout the translation directory from
11) # https://svn.torproject.org, and clone the tor repository from
12) # git.torproject.org.
13) #	
14) 
15) ### Start config ###
16) 
17) # Location of the translated manpages
18) translated="$PWD"
19) 
20) # Location of the website directory
21) wml="`dirname $translated`"
22) 
23) # Location of the English manpages. Assuming that the git clone of the
24) # tor repository is relative to the website
25) mandir="`dirname $wml`/tor/doc"
26) 
27) # Location of the po files. Assuming that the translation directory is
28) # relative to the website
29) podir="`dirname $wml`/translation/projects/manpages/po"
30) 
31) ### End config ###
32) 
33) # Find po files to convert
34) po=`find $podir -type f -name \*.1.po`
35) 
36) # For every po found, create and/or update the translated manpage.
37) for file in $po ; do
38) 
39) 	# Get the basename of the file we are dealing with
40) 	pofile=`basename $file`
41) 
42) 	# Strip the file for its original extension and add .txt
43) 	manfile="${pofile%.*}.txt"
44) 
45) 	# Figure out which language we are dealing with.
46) 	lang=`dirname $file | sed "s#$podir/##"`
47) 
48) 	# The translated document is written if 80% or more of the po
49) 	# file has been translated. Also, po4a-translate will only write
50) 	# the translated document if 80% or more has been translated.
51) 	# However, it will delete the translated txt if less than 80%
52) 	# has been translated. To avoid having our current, translated
53) 	# txt files deleted, convert the po to a temp txt first. If this
54) 	# file was actually written, rename it to txt.
55) 
56) 	# Convert translated po files back to manpages.
57) 	function convert {
58) 		po4a-translate -f text -m "$mandir/$manfile" -p "$file"  -l "$translated/$lang/tmp-$manfile" --master-charset utf-8 -L utf-8
59) 
60) 		# Check to see if the file was written. If yes, rename
61) 		# it.
62) 		if [ -e "$translated/$lang/tmp-$manfile" ]
63) 		then
64) 			mv "$translated/$lang/tmp-$manfile" "$translated/$lang/$manfile"
65) 
66) 			# If tor.1.po has been translated, we need to
67) 			# create tor-manual-dev.wml in the correct
68) 			# language directory.
69) 			if [ $manfile = "tor.1.txt" ]
70) 			then
71) 				if [ ! -e "$wml/docs/$lang/tor-manual-dev.wml" ]
72) 				then
73) 
74) 					if [ ! -d "$wml/docs/$lang/" ]
75) 					then
76) 						mkdir "$wml/docs/$lang/"
77) 					fi
78) 
79) 					# Copy template file for
80) 					# tor-manual-dev.wml, and
81) 					# replace "lang" with the
82) 					# correct name of the language
83) 					# directory.
Runa A. Sandvik cleaning up the manpage dir...

Runa A. Sandvik authored 13 years ago

84) 					cp "$translated/en/tor-manual-dev.wml" "$wml/docs/$lang"