1 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,126 +0,0 @@ |
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 |
- # Validate input and write results to a log file |
|
40 |
- validate_script="/home/runa/tor/translation/tools/validate.py" |
|
41 |
- validate_log="/home/runa/tor/validate/manpages-validate.log" |
|
42 |
- python "$validate_script" -i "$file" -l "$validate_log" |
|
43 |
- |
|
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. |
|
89 |
- cp "$translated/en/tor-manual-dev.wml" "$wml/docs/$lang" |
|
90 |
- sed -i "0,/lang/ s/lang/"$lang"/" "$wml/docs/$lang/tor-manual-dev.wml" |
|
91 |
- fi |
|
92 |
- fi |
|
93 |
- fi |
|
94 |
- } |
|
95 |
- |
|
96 |
- # We have a few cases where the name of the language directory |
|
97 |
- # in the translations module is not equal the name of the |
|
98 |
- # language directory in the website module. |
|
99 |
- |
|
100 |
- # For "zh_CN" use "zh-cn" instead |
|
101 |
- if [ $lang = "zh_CN" ] |
|
102 |
- then |
|
103 |
- lang="zh-cn" |
|
104 |
- convert |
|
105 |
- fi |
|
106 |
- |
|
107 |
- # For "nb" use "no" instead |
|
108 |
- if [ $lang = "nb" ] |
|
109 |
- then |
|
110 |
- lang="no" |
|
111 |
- convert |
|
112 |
- fi |
|
113 |
- |
|
114 |
- # For "sv" use "se" instead |
|
115 |
- if [ $lang = "sv" ] |
|
116 |
- then |
|
117 |
- lang="se" |
|
118 |
- convert |
|
119 |
- fi |
|
120 |
- |
|
121 |
- # Convert everything else |
|
122 |
- if [[ $lang != "zh_CN" && $lang != "nb" && $lang != "sv" ]] |
|
123 |
- then |
|
124 |
- convert |
|
125 |
- fi |
|
126 |
-done |
... | ... |
@@ -37,8 +37,8 @@ po=`find $podir -type f -name \*.1.po` |
37 | 37 |
for file in $po ; do |
38 | 38 |
|
39 | 39 |
# Validate input and write results to a log file |
40 |
- validate_script="`dirname $wmldir`/translation/tools/validate.py" |
|
41 |
- validate_log="`dirname $wmldir`/manpages-validate.log" |
|
40 |
+ validate_script="/home/runa/tor/translation/tools/validate.py" |
|
41 |
+ validate_log="/home/runa/tor/validate/manpages-validate.log" |
|
42 | 42 |
python "$validate_script" -i "$file" -l "$validate_log" |
43 | 43 |
|
44 | 44 |
# Get the basename of the file we are dealing with |
... | ... |
@@ -36,6 +36,11 @@ po=`find $podir -type f -name \*.1.po` |
36 | 36 |
# For every po found, create and/or update the translated manpage. |
37 | 37 |
for file in $po ; do |
38 | 38 |
|
39 |
+ # Validate input and write results to a log file |
|
40 |
+ validate_script="`dirname $wmldir`/translation/tools/validate.py" |
|
41 |
+ validate_log="`dirname $wmldir`/manpages-validate.log" |
|
42 |
+ python "$validate_script" -i "$file" -l "$validate_log" |
|
43 |
+ |
|
39 | 44 |
# Get the basename of the file we are dealing with |
40 | 45 |
pofile=`basename $file` |
41 | 46 |
|
... | ... |
@@ -81,7 +81,7 @@ for file in $po ; do |
81 | 81 |
# replace "lang" with the |
82 | 82 |
# correct name of the language |
83 | 83 |
# directory. |
84 |
- cp "$translated/tor-manual-dev.wml" "$wml/docs/$lang" |
|
84 |
+ cp "$translated/en/tor-manual-dev.wml" "$wml/docs/$lang" |
|
85 | 85 |
sed -i "0,/lang/ s/lang/"$lang"/" "$wml/docs/$lang/tor-manual-dev.wml" |
86 | 86 |
fi |
87 | 87 |
fi |
1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,121 @@ |
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. |
|
84 |
+ cp "$translated/tor-manual-dev.wml" "$wml/docs/$lang" |
|
85 |
+ sed -i "0,/lang/ s/lang/"$lang"/" "$wml/docs/$lang/tor-manual-dev.wml" |
|
86 |
+ fi |
|
87 |
+ fi |
|
88 |
+ fi |
|
89 |
+ } |
|
90 |
+ |
|
91 |
+ # We have a few cases where the name of the language directory |
|
92 |
+ # in the translations module is not equal the name of the |
|
93 |
+ # language directory in the website module. |
|
94 |
+ |
|
95 |
+ # For "zh_CN" use "zh-cn" instead |
|
96 |
+ if [ $lang = "zh_CN" ] |
|
97 |
+ then |
|
98 |
+ lang="zh-cn" |
|
99 |
+ convert |
|
100 |
+ fi |
|
101 |
+ |
|
102 |
+ # For "nb" use "no" instead |
|
103 |
+ if [ $lang = "nb" ] |
|
104 |
+ then |
|
105 |
+ lang="no" |
|
106 |
+ convert |
|
107 |
+ fi |
|
108 |
+ |
|
109 |
+ # For "sv" use "se" instead |
|
110 |
+ if [ $lang = "sv" ] |
|
111 |
+ then |
|
112 |
+ lang="se" |
|
113 |
+ convert |
|
114 |
+ fi |
|
115 |
+ |
|
116 |
+ # Convert everything else |
|
117 |
+ if [[ $lang != "zh_CN" && $lang != "nb" && $lang != "sv" ]] |
|
118 |
+ then |
|
119 |
+ convert |
|
120 |
+ fi |
|
121 |
+done |