Runa A. Sandvik commited on 2009-09-25 18:12:04
Zeige 1 geänderte Dateien mit 38 Einfügungen und 25 Löschungen.
| ... | ... |
@@ -6,8 +6,9 @@ |
| 6 | 6 |
# This is Free Software (GPLv3) |
| 7 | 7 |
# http://www.gnu.org/licenses/gpl-3.0.txt |
| 8 | 8 |
# |
| 9 |
-# This script will convert all of the english wml files to pot files and |
|
| 10 |
-# keep them updated. |
|
| 9 |
+# This script will convert all of the english wml files to po files, and |
|
| 10 |
+# keep them updated. The script will also convert subdirectories that |
|
| 11 |
+# exist in the english website module. |
|
| 11 | 12 |
# |
| 12 | 13 |
# For more information, see the HOWTO and README in |
| 13 | 14 |
# translation/tools/gsoc09. |
| ... | ... |
@@ -18,11 +19,11 @@ |
| 18 | 19 |
# Location of the wml files |
| 19 | 20 |
wmldir="$PWD" |
| 20 | 21 |
|
| 21 |
-# Location of the pot files. |
|
| 22 |
+# Location of the po files. |
|
| 22 | 23 |
# Assuming that the translation directory is relative to the website |
| 23 |
-podir="`dirname $wmldir`/translation/projects/website/templates" |
|
| 24 |
+podir="`dirname $wmldir`/translation/projects/website" |
|
| 24 | 25 |
|
| 25 |
-# Set the copyright holder of the pot files, |
|
| 26 |
+# Set the copyright holder of the po files, |
|
| 26 | 27 |
# for example "The Tor Project, Inc" |
| 27 | 28 |
copyright="The Tor Project, Inc" |
| 28 | 29 |
|
| ... | ... |
@@ -75,14 +76,20 @@ fi |
| 75 | 76 |
# Create the temp log |
| 76 | 77 |
touch $tmplog |
| 77 | 78 |
|
| 78 |
-# cd to the right directory so we can commit the files later |
|
| 79 |
-cd "$podir" |
|
| 79 |
+# We need to find out which language directories we have. |
|
| 80 |
+# We also need to excluse the website module directory itself, as well |
|
| 81 |
+# as .svn |
|
| 82 |
+langdir=`find "$podir" -maxdepth 1 -type d ! -path "$podir" ! -path "$podir/templates" ! -path "*\.*" | sed "s#$podir/##"` |
|
| 80 | 83 |
|
| 81 | 84 |
# We only need the english wml files, but we do not wish to translate |
| 82 | 85 |
# the eff documents. |
| 83 | 86 |
wml=`find $wmldir -regex '^'$wmldir'/.*en/.*\.wml' -type f | grep -v '^'$wmldir'/eff'` |
| 84 | 87 |
|
| 85 |
-# For every wml, update po |
|
| 88 |
+# For every language directory, create and/or update the po files. |
|
| 89 |
+for lang in $langdir ; do |
|
| 90 |
+ |
|
| 91 |
+ # For every english wml, see if the po needs to be created or |
|
| 92 |
+ # updated |
|
| 86 | 93 |
for file in $wml ; do |
| 87 | 94 |
|
| 88 | 95 |
# Get the basename of the file we are dealing with |
| ... | ... |
@@ -99,8 +106,8 @@ for file in $wml ; do |
| 99 | 106 |
continue |
| 100 | 107 |
fi |
| 101 | 108 |
|
| 102 |
- # Strip the file for its original extension and add .pot |
|
| 103 |
- pofile="$priority.${wmlfile%%.*}.pot"
|
|
| 109 |
+ # Strip the file for its original extension and add .po |
|
| 110 |
+ pofile="$priority.${wmlfile%%.*}.po"
|
|
| 104 | 111 |
|
| 105 | 112 |
# Find out what directory the file is in. |
| 106 | 113 |
# Also, remove the parth of the path that is $wmldir |
| ... | ... |
@@ -109,33 +116,35 @@ for file in $wml ; do |
| 109 | 116 |
# We need to know what one dir up is |
| 110 | 117 |
onedirup=`dirname $indir | sed "s#$wmldir/##"` |
| 111 | 118 |
|
| 112 |
- # We need to have the correct, full path to the pot |
|
| 119 |
+ # We need to have the correct, full path to the po |
|
| 113 | 120 |
# directory for the file we are working on. |
| 114 | 121 |
# Also, did the subdirectory exist prior to running this |
| 115 | 122 |
# script? If not, create it now and add it to the |
| 116 | 123 |
# repository. |
| 117 | 124 |
if [ $onedirup = $wmldir ] |
| 118 | 125 |
then |
| 119 |
- popath="$podir" |
|
| 126 |
+ popath="$podir/$lang" |
|
| 120 | 127 |
else |
| 128 |
+ |
|
| 121 | 129 |
# We need to know if a subdirectory, such as torbutton, |
| 122 | 130 |
# exist in the translation module. If it does not exist, |
| 123 | 131 |
# the script will create it in all the directories under |
| 124 | 132 |
# translation/projects/website (excluding .svn) |
| 125 |
- langdir=`find $(dirname "$podir") -maxdepth 1 -type d ! -path $(dirname "$podir") ! -path "*\.*"` |
|
| 133 |
+ subdir=`find "$podir/$lang" -maxdepth 1 -type d ! -path "$ppodir/$lang" ! -path "*\.*"` |
|
| 126 | 134 |
|
| 127 |
- for dir in $langdir ; do |
|
| 128 |
- if [ ! -d "$dir/$onedirup" ] |
|
| 135 |
+ for dir in $subdir ; do |
|
| 136 |
+ if [ ! -d "$podir/$lang/$onedirup" ] |
|
| 129 | 137 |
then |
| 130 |
- svn mkdir "$dir/$onedirup" |
|
| 138 |
+ svn mkdir "$podir/$lang/$onedirup" |
|
| 131 | 139 |
fi |
| 132 | 140 |
done |
| 133 | 141 |
|
| 134 | 142 |
# Set the path |
| 135 |
- popath="$podir/$onedirup" |
|
| 143 |
+ popath="$podir/$lang/$onedirup" |
|
| 144 |
+ |
|
| 136 | 145 |
fi |
| 137 | 146 |
|
| 138 |
- # Check to see if the pot file existed prior to running this |
|
| 147 |
+ # Check to see if the po existed prior to running this |
|
| 139 | 148 |
# script. If it didn't, check if there any files with the same |
| 140 | 149 |
# filename, but different priority. If neither of the files |
| 141 | 150 |
# exist, create with po4a-gettextize. |
| ... | ... |
@@ -155,7 +165,7 @@ for file in $wml ; do |
| 155 | 165 |
poexist=0 |
| 156 | 166 |
fi |
| 157 | 167 |
|
| 158 |
- # If the pot file does not exist, convert it with |
|
| 168 |
+ # If the po file does not exist, convert it with |
|
| 159 | 169 |
# po4a-gettextize, set the right encoding and charset |
| 160 | 170 |
# and the correct copyright. |
| 161 | 171 |
if [ $poexist = 0 ] |
| ... | ... |
@@ -188,16 +198,23 @@ for file in $wml ; do |
| 188 | 198 |
echo "$popath/$pofile" > $tmplog |
| 189 | 199 |
fi |
| 190 | 200 |
fi |
| 201 |
+ |
|
| 202 |
+ # Update the file with po4a-updatepo to make the |
|
| 203 |
+ # word wrapping perfect |
|
| 204 |
+ po4a-updatepo -f wml -m "$file" -p "$popath/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault" |
|
| 205 |
+ |
|
| 206 |
+ # Delete the backup |
|
| 207 |
+ rm -f "$popath/$pofile~" |
|
| 191 | 208 |
fi |
| 192 | 209 |
|
| 193 |
- # If the pot file does exist, calculate the hash first, |
|
| 210 |
+ # If the po file does exist, calculate the hash first, |
|
| 194 | 211 |
# then update the file, then calculate the hash again. |
| 195 | 212 |
if [ $poexist = 1 ] |
| 196 | 213 |
then |
| 197 | 214 |
# Calculate the hash before we update the file |
| 198 | 215 |
before=`grep -vE '^("POT-Creation-Date:|#)' "$popath/$pofile" | md5sum | cut -d " " -f1`
|
| 199 | 216 |
|
| 200 |
- # Update the pot file |
|
| 217 |
+ # Update the po file |
|
| 201 | 218 |
po4a-updatepo -f wml -m "$file" -p "$popath/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault" |
| 202 | 219 |
|
| 203 | 220 |
# Calculate the new hash |
| ... | ... |
@@ -240,7 +257,4 @@ for file in $wml ; do |
| 240 | 257 |
# Delete the temp log |
| 241 | 258 |
rm -f $tmplog |
| 242 | 259 |
done |
| 243 |
- |
|
| 244 |
- # If you want the script to commit the files automatically, |
|
| 245 |
- # uncomment the following line. |
|
| 246 |
- # svn ci -m 'automatically generated and updated the pot files' |
|
| 260 |
+done |
|
| 247 | 261 |