[or-cvs] r20320: {} moved the scripts (translation/trunk/tools/gsoc09)

runa at seul.org runa at seul.org
Sun Aug 16 08:10:59 UTC 2009


Author: runa
Date: 2009-08-16 04:10:59 -0400 (Sun, 16 Aug 2009)
New Revision: 20320

Removed:
   translation/trunk/tools/gsoc09/po2wml.sh
   translation/trunk/tools/gsoc09/wml2po.sh
Log:
moved the scripts

Deleted: translation/trunk/tools/gsoc09/po2wml.sh
===================================================================
--- translation/trunk/tools/gsoc09/po2wml.sh	2009-08-16 08:10:13 UTC (rev 20319)
+++ translation/trunk/tools/gsoc09/po2wml.sh	2009-08-16 08:10:59 UTC (rev 20320)
@@ -1,120 +0,0 @@
-#!/bin/bash
-#
-# Author: Runa Sandvik, <runa.sandvik at gmail.com>
-# Google Summer of Code 2009
-#
-# This script will convert all the translated po files back to wml
-# files.
-#
-
-### start config ###
-
-# Location of the wml files, 
-# for example "/home/runa/tor/website"
-wmldir=""
-
-# Location of the po files,
-# for example "/home/runa/tor/translation/projects/website"
-podir=""
-
-# A lot of the wml files have custom tags. These tags have been defined
-# in website/include/versions.wmi. Tags that people usually forget to close,
-# as well as tags that are not defined in versions.wmi have been added.
-# See: https://svn.torproject.org/svn/website/trunk/include/versions.wmi
-customtag=`echo $(cat "$wmldir/include/versions.wmi" | awk '{ printf "<%s> " , $2 }' | sed 's/<>//g') "<svnsandbox> <svnwebsite> <input> <hr> <br> <img>"`
-
-# We also need to use the nodefault option of po4a; space separated list
-# of tags that the module should not try to set by default in any
-# category. For now, we only need the input tag.
-nodefault='<input>'
-
-### end config ###
-
-# Create a lockfile to make sure that only one instance of the script
-# can run at any time.
-LOCKFILE=po2wml.lock
-
-if lockfile -! -l 60 -r 3 "$LOCKFILE"; 
-then
-	echo "unable to acquire lock" >2
-	exit 1
-fi
-
-trap "rm -f '$PWD/$LOCKFILE'" exit
-
-# cd to the right directory so we can commit the files later
-cd "$wmldir"
-
-# We need to find the po files
-po=`find $podir -regex '^'$podir'/.*/.*\.po' -type f`
-
-# For every wml, update po
-for file in $po ; do
-	
-	# Get the basename of the file we are dealing with
-	pofile=`basename $file`
-
-	# Strip the file for its original extension and the translation
-	# priority, and add .wml
-	wmlfile="`echo $pofile | cut -d . -f 2`.wml"	
-
-	# Find out what directory the file is in.
-	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.
-	# 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
-	# translated. To avoid having our current, translated wml files
-	# deleted, we first convert the po to a temp wml. If this file
-	# was written, we'll rename it.
-
-	# 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
-		# The location of the english wml file
-		english="$wmldir/en/$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

Deleted: translation/trunk/tools/gsoc09/wml2po.sh
===================================================================
--- translation/trunk/tools/gsoc09/wml2po.sh	2009-08-16 08:10:13 UTC (rev 20319)
+++ translation/trunk/tools/gsoc09/wml2po.sh	2009-08-16 08:10:59 UTC (rev 20320)
@@ -1,236 +0,0 @@
-#!/bin/bash
-#
-# Author: Runa Sandvik, <runa.sandvik at gmail.com>
-# Google Summer of Code 2009
-#
-# This script will convert all of the english wml files to pot files and
-# keep them updated.
-#
-
-### start config ###
-
-# Location of the wml files, 
-# for example "/home/runa/tor/website".
-# Note: do not put a slash at the end
-wmldir=""
-
-# Location of the pot files (usually in the templates-folder),
-# for example "/home/runa/tor/translation/projects/website/templates".
-# Note: do not put a slash at the end
-podir=""
-
-# Set the copyright holder of the pot files,
-# for example "The Tor Project, Inc"
-copyright=""
-
-# A lot of the wml files have custom tags. These tags have been defined
-# in website/include/versions.wmi. Tags that people usually forget to close,
-# as well as tags that are not defined in versions.wmi have been added.
-# See: https://svn.torproject.org/svn/website/trunk/include/versions.wmi
-customtag=`echo $(cat "$wmldir/include/versions.wmi" | awk '{ printf "<%s> " , $2 }' | sed 's/<>//g') "<svnsandbox> <svnwebsite> <input> <hr> <br> <img>"`
-
-# We also need to use the nodefault option of po4a; space separated list
-# of tags that the module should not try to set by default in any
-# category. For now, we only need the input tag.
-nodefault='<input>'
-
-# The script can write the name of unprocessed files to a log.
-# If you want to enable this option, set the logfile here.
-logfile=""
-
-# This is the temp logfile. Leave this line even if you don't want to
-# log. This will be deleted when the script is done.
-tmplog="`dirname $wmldir`/tmp.log"
-
-### end config ###
-
-# Create a lockfile to make sure that only one instance of the script
-# can run at any time.
-LOCKFILE=wml2po.lock
-
-if lockfile -! -l 60 -r 3 "$LOCKFILE"; 
-then
-	echo "unable to acquire lock" >2
-	exit 1
-fi
-
-trap "rm -f '$PWD/$LOCKFILE'" exit
-
-# If the logfile is set, write the date.
-if [ $logfile ]
-then
-	echo `date` > $logfile
-fi
-
-# Create the temp log
-touch $tmplog
-
-# cd to the right directory so we can commit the files later
-cd "$podir"
-
-# We only need the english wml files, but we do not wish to translate
-# the eff documents.
-wml=`find $wmldir -regex '^'$wmldir'/.*en/.*\.wml' -type f | grep -v '^'$wmldir'/eff'`
-
-# For every wml, update po
-for file in $wml ; do
-
-	# Get the basename of the file we are dealing with
-	wmlfile=`basename $file`
-
-	# Get the translation priority
-	priority=`cat $file | grep "# Translation-Priority" | awk '{print $3}'`
-
-	# If the file doesn't have a translation-priority, we can assume
-	# that it doesn't need to be translated. Skip this file and
-	# continue on with the next.
-	if [ ! $priority ]
-	then
-		continue
-	fi
-
-	# Strip the file for its original extension and add .pot
-	pofile="$priority.${wmlfile%%.*}.pot"
-
-	# Find out what directory the file is in.
-	# Also, remove the parth of the path that is $wmldir
-	indir=`dirname $file`
-	
-	# We need to know what one dir up is
-	onedirup=`dirname $indir | sed "s#$wmldir/##"`
-
-	# We need to have the correct, full path to the pot
-	# directory for the file we are working on.
-	# Also, did the subdirectory exist prior to running this
-	# script? If not, create it now and add it to the
-	# repository.
-	if [ $onedirup = $wmldir ]
-	then
-		popath="$podir/$dir"
-
-		# Check if the directory exists. If it doesn't,
-		# create it
-		if [ ! -d "$podir/$dir" ]
-		then
-			svn mkdir "$podir/$dir"
-		fi
-	else
-		popath="$podir/$dir/$onedirup"
-
-		# Check if the directory exists. If it doesn't,
-		# create it.
-		if [ ! -d "$podir/$dir/$onedirup" ]
-		then
-			svn mkdir "$podir/$dir/$onedirup"
-		fi
-	fi
-		
-	# Check to see if the pot file existed prior to running this
-	# script. If it didn't, check if there any files with the same
-	# filename, but different priority. If neither of the files
-	# exist, create with po4a-gettextize.
-	if [ -e "$popath/$pofile" ]
-	then
-		poexist=1
-	elif [ `find $popath -type f -name "*.$filename" | wc -l` -gt "0" ]
-	then
-		poexist=2
-
-		# We need to rename the other file
-		for file in `find $popath -type f -name "*.$filename"` ; do
-			svn mv "$file" "$popath/$pofile"
-			echo "$popath/$pofile" > $tmplog
-		done
-	else
-		poexist=0
-	fi
-
-	# If the pot file does not exist, convert it with
-	# po4a-gettextize, set the right encoding and charset
-	# and the correct copyright.
-	if [ $poexist = 0 ]
-	then
-		# Convert it
-		po4a-gettextize -f wml -m "$file" -p "$popath/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
-
-		# Check to see if the file exists
-		if [ -e "$popath/$pofile" ]
-		then
-			# We don't want files without
-			# content, so check the file first.
-			content=`cat "$popath/$pofile" | grep '^#[.]' | wc -l`
-
-			# If the file does not have any
-			# content, delete it.
-			if [ $content = 0 ] 
-			then
-				rm -f "$popath/$pofile"
-				echo "$popath/$pofile" > $tmplog
-			else
-				# Set the right encoding and charset, as well
-				# as the correct copyright holder.
-				sed -i '0,/ENCODING/ s/ENCODING/8bit/' "$popath/$pofile"
-				sed -i '0,/CHARSET/ s/CHARSET/utf-8/' "$popath/$pofile"
-				sed -i "0,/Free Software Foundation, Inc/ s/Free Software Foundation, Inc/$copyright/" "$popath/$pofile"
-
-				# And add it to the repository
-				svn add "$popath/$pofile"
-				echo "$popath/$pofile" > $tmplog
-			fi
-		fi
-	fi
-		
-	# If the pot file does exist, calculate the hash first,
-	# then update the file, then calculate the hash again.
-	if [ $poexist = 1 ]
-	then
-		# Calculate the hash before we update the file
-		before=`grep -vE '^("POT-Creation-Date:|#)' "$popath/$pofile" | md5sum | cut -d " " -f1`
-
-		# Update the pot file
-		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/$pofile" | md5sum | cut -d " " -f1`
-
-		# Delete the backup
-		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/$pofile"
-			echo "$popath/$pofile" > $tmplog
-		else
-			echo "$popath/$pofile" > $tmplog
-		fi
-	fi
-
-	# If a file with the same name but different priority
-	# exist, then rename the file (we have done so already)
-	# and update it with po4a-updatepo to make sure
-	# everything else is ok.
-	if [ $poexist = 2 ]
-	then
-		# Update the file
-		po4a-updatepo -f wml -m "$file" -p "$popath/$pofile" --master-charset utf-8 -o customtag="$customtag" -o nodefault="$nodefault"
-	fi
-	
-	# Write to the logfile
-	if [ -e $logfile ]
-	then
-		if [ `cat $tmplog | grep "$popath/$pofile" | wc -l` -eq "0" ]
-		then
-			echo "could not process: " "$file" >> $logfile
-		fi
-	fi
-
-	# Delete the temp log
-	rm -f $tmplog
-done
-
-	# If you want the script to commit the files automatically,
-	# uncomment the following line.
-	# svn ci -m 'automatically generated and updated the pot files'



More information about the tor-commits mailing list