[or-cvs] r20138: {translation} fix for a different directory structure (translation/trunk/tools/gsoc09)

runa at seul.org runa at seul.org
Fri Jul 24 18:27:03 UTC 2009


Author: runa
Date: 2009-07-24 14:27:03 -0400 (Fri, 24 Jul 2009)
New Revision: 20138

Modified:
   translation/trunk/tools/gsoc09/wml2po.sh
Log:
fix for a different directory structure

Modified: translation/trunk/tools/gsoc09/wml2po.sh
===================================================================
--- translation/trunk/tools/gsoc09/wml2po.sh	2009-07-24 15:49:02 UTC (rev 20137)
+++ translation/trunk/tools/gsoc09/wml2po.sh	2009-07-24 18:27:03 UTC (rev 20138)
@@ -67,18 +67,27 @@
 
 	# Find out what directory the file is in.
 	# Also, remove the parth of the path that is $wmldir
-	indir=`dirname $file | sed "s#$wmldir/##"`
+	indir=`dirname $file`
+	
+	# We need to know what one dir up is
+	onedirup=`dirname $indir | sed "s#$wmldir/##"`
 
-	# The path to the directory where the po files are
-	popath=`dirname "$podir/$indir"`
-
 	# Make sure the po file exist in every language directory
 	for dir in $lang ; do
+
+		# We need to have the correct, full path to the po
+		# directory for the file we are working on
+		if [ $onedirup = $wmldir ]
+		then
+			popath="$podir/$dir"
+		else
+			popath="$podir/$dir/$onedirup"
+		fi
 		
 		# We need to know if the po file exist before we run
 		# po4a-updatepo. If it doesn't, po4a-gettextize will
 		# create it.
-		if [ -e "$popath/$dir/$pofile" ]
+		if [ -e "$popath/$pofile" ]
 		then
 			poexist=1
 		else
@@ -91,31 +100,31 @@
 		if [ $poexist = 0 ]
 		then
 			# Convert it
-			po4a-gettextize -f wml -m "$file" -p "$popath/$dir/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault" --copyright-holder "$copyright"
+			po4a-gettextize -f wml -m "$file" -p "$popath/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault" --copyright-holder "$copyright"
 
 			# Check to see if the file exists
-			if [ -e "$popath/$dir/$pofile" ]
+			if [ -e "$popath/$pofile" ]
 			then
 				
 				# We don't want po files without
 				# content, so check the file first.
-				content=`cat "$popath/$dir/$pofile" | grep '^#[.]' | wc -l`
+				content=`cat "$popath/$pofile" | grep '^#[.]' | wc -l`
 
 				# If the po file does not have any
 				# content, delete it.
 				if [ $content = 0 ] 
 				then
-					rm -f "$popath/$dir/$pofile"
+					rm -f "$popath/$pofile"
 				fi
 
 				if [ $content != 0 ]
 				then
 					# Set the right encoding and charset
-					sed -i '1,/CHARSET/ s/CHARSET/UTF-8/' "$popath/$dir/$pofile"
-					sed -i '1,/ENCODING/ s/ENCODING/8bit/' "$popath/$dir/$pofile"
+					sed -i '1,/CHARSET/ s/CHARSET/UTF-8/' "$popath/$pofile"
+					sed -i '1,/ENCODING/ s/ENCODING/8bit/' "$popath/$pofile"
 
 					# And add it to the repository
-					svn add "$popath/$dir/$pofile"
+					svn add "$popath/$pofile"
 				fi
 			fi
 		fi
@@ -125,23 +134,23 @@
 		if [ $poexist = 1 ]
 		then
 			# Calculate the hash before we update the file
-			before=`grep -vE '^("POT-Creation-Date:|#)' "$popath/$dir/$pofile" | md5sum | cut -d " " -f1`
+			before=`grep -vE '^("POT-Creation-Date:|#)' "$popath/$pofile" | md5sum | cut -d " " -f1`
 
 			# Update the po file
-			po4a-updatepo -f wml -m "$file" -p "$popath/$dir/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
+			po4a-updatepo -f wml -m "$file" -p "$popath/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
 
 			# Calculate the new hash
-			after=`grep -vE '^("POT-Creation-Date:|#)' "$popath/$dir/$pofile" | md5sum | cut -d " "	-f1`
+			after=`grep -vE '^("POT-Creation-Date:|#)' "$popath/$pofile" | md5sum | cut -d " " -f1`
 
 			# Delete the backup
-			rm -f "$popath/$dir/$pofile~"
+			rm -f "$popath/$pofile~"
 
 			# Now we need to compare the before and after
 			# hash. If they match (i.e. nothing has
 			# changed), revert the file.
 			if [ $before = $after ]
 			then
-				svn revert "$popath/$dir/$pofile"
+				svn revert "$popath/$pofile"
 			fi
 		fi
 



More information about the tor-commits mailing list