[or-cvs] r19942: {} added the script that will convert translated po files back (translation/trunk/tools/gsoc09)
runa at seul.org
runa at seul.org
Tue Jul 7 13:33:29 UTC 2009
Author: runa
Date: 2009-07-07 09:33:29 -0400 (Tue, 07 Jul 2009)
New Revision: 19942
Added:
translation/trunk/tools/gsoc09/po2wml.sh
Log:
added the script that will convert translated po files back to wml files
Added: translation/trunk/tools/gsoc09/po2wml.sh
===================================================================
--- translation/trunk/tools/gsoc09/po2wml.sh (rev 0)
+++ translation/trunk/tools/gsoc09/po2wml.sh 2009-07-07 13:33:29 UTC (rev 19942)
@@ -0,0 +1,84 @@
+#!/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=""
+
+### 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 '$LOCKFILE'" exit
+
+# 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 add .wml
+ 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"
+
+ # We need to know if the wml file exist before we run
+ # po4a-translate. If it doesn't, po4a-translate will
+ # create it.
+ if [ -e "$wmldir/$indir/$wmlfile" ]
+ then
+ wmlexist=1
+ else
+ wmlexist=0
+ fi
+
+ # Write the translated wml file.
+ # The translated document is written if 80% or more of the po
+ # file has been translated. Use '-k 21' to set this
+ # number down to 21%.
+ po4a-translate -f wml -m "$endir/$wmlfile" -p "$file" -l "$wmldir/$indir/$wmlfile" --master-charset utf-8 -L utf-8
+
+ # If the file did not exist before running
+ # po4a-translate but it does exist now, add the file to
+ # the repository.
+ if [ $wmlexist = 0 ]
+ then
+ if [ -e "$wmldir/$indir/$wmlfile" ]
+ then
+ # Add it to the repository
+ svn add "$wmldir/$indir/$wmlfile"
+ fi
+ fi
+
+ # Commit the files
+ svn ci -m 'automatically updated the translated documents'
+done
Property changes on: translation/trunk/tools/gsoc09/po2wml.sh
___________________________________________________________________
Added: svn:executable
+ *
More information about the tor-commits
mailing list