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