[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



Author: runa
Date: 2009-07-26 11:29:52 -0400 (Sun, 26 Jul 2009)
New Revision: 20150

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

Modified: translation/trunk/tools/gsoc09/po2wml.sh
===================================================================
--- translation/trunk/tools/gsoc09/po2wml.sh	2009-07-26 15:07:03 UTC (rev 20149)
+++ translation/trunk/tools/gsoc09/po2wml.sh	2009-07-26 15:29:52 UTC (rev 20150)
@@ -56,18 +56,22 @@
 	wmlfile="${pofile%%.*}.wml"
 
 	# Find out what directory the file is in.
-	# Also, remove the parth of the path that is $wmldir
-	indir=`dirname $file | sed "s#$podir/##"`
-	
-	# We need to be in the english directory
-	onedirup=`dirname "$wmldir/$indir"`
-	endir="$onedirup/en"
+	indir=`dirname $file`
 
+	# We also need to know what one directory up is
+	onedirup=`dirname $indir`
+
+	# We need to find out what subdirectory we are in
+	subdir=`dirname $file | sed "s#$onedirup/##"`
+
+	# And which language we are dealing with
+	lang=`dirname $indir | sed "s#$podir/##"`
+
 	# Time to write the translated wml file.
 	# The translated document is written if 80% or more of the po
-	# file has been translated. 
+	# file has been translated.
 	# Example: Use '-k 21' to set this number down to 21%.
-
+	
 	# The nice thing with po4a-translate is that it will only write
 	# the translated document if 80% or more has been translated.
 	# But it will delete the wml if less than 80% has been
@@ -75,17 +79,39 @@
 	# deleted, we first convert the po to a temp wml. If this file
 	# was written, we'll rename it.
 
-	# Also, we don't want to convert english po back to english wml
-	if [ "$indir" != "en" ]
+	# If $onedirup is equal to $lang, that means we do not have a
+	# subdirectory. Also, we don't want to convert english po back
+	# to english wml.
+	if [ $onedirup == $lang ]
 	then
-		po4a-translate -f wml -m "$endir/$wmlfile" -p "$file" -l "$wmldir/$indir/$indir-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
-	fi
+		# The location of the english wml file
+		english="$wmldir/en/$wmlfile"
 
-	# Check to see if the file was written
-	if [ -e "$wmldir/$indir/$indir-$wmlfile" ]
-	then
-		# If it was written, rename it
-		mv "$wmldir/$indir/$indir-$wmlfile" "$wmldir/$indir/$wmlfile"
+		# Convert everything but the english po files
+		if [ $subdir != "en" ]
+		then
+			po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
 
+			# Check to see if the file was written
+			if [ -e "$wmldir/$subdir/tmp-$wmlfile" ]
+			then
+				mv "$wmldir/$subdir/tmp-$wmlfile" "$wmldir/$subdir/$wmlfile"
+			fi
+		fi
+	else
+		# The location of the english wml file
+		english="$wmldir/$subdir/en/$wmlfile"
+		
+		# Convert everything but the english po files
+		if [ $lang != "en" ]
+		then
+			po4a-translate -f wml -m "$english" -p "$file" -l "$wmldir/$subdir/$lang/tmp-$wmlfile" --master-charset utf-8 -L utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
+
+			# Check to see if the file was written
+			if [ -e "$wmldir/$subdir/$lang/tmp-$wmlfile" ]
+			then
+				mv "$wmldir/$subdir/$lang/tmp-$wmlfile" "$wmldir/$subdir/$lang/$wmlfile"
+			fi
+		fi
 	fi
 done