[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r20193: {translation} translation priority in filename (translation/trunk/tools/gsoc09)
Author: runa
Date: 2009-07-29 08:42:17 -0400 (Wed, 29 Jul 2009)
New Revision: 20193
Modified:
translation/trunk/tools/gsoc09/wml2po.sh
Log:
translation priority in filename
Modified: translation/trunk/tools/gsoc09/wml2po.sh
===================================================================
--- translation/trunk/tools/gsoc09/wml2po.sh 2009-07-29 04:35:54 UTC (rev 20192)
+++ translation/trunk/tools/gsoc09/wml2po.sh 2009-07-29 12:42:17 UTC (rev 20193)
@@ -27,9 +27,9 @@
copyright=""
# A lot of the wml files have custom tags. These tags have been defined
-# in website/include/versions.wmi. I have also added the tags that
-# people usually forget to close.
-customtag=`echo $(cat "$wmldir/include/versions.wmi" | awk '{ printf "<%s> " , $2 }' | sed 's/<>//g') "<input> <hr> <br> <img>"`
+# 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.
+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
@@ -64,8 +64,22 @@
wmlfile=`basename $file`
# Strip the file for its original extension and add .po
- pofile="${wmlfile%%.*}.po"
+ filename="${wmlfile%%.*}.po"
+ # 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 .po
+ pofile="$priority.${wmlfile%%.*}.po"
+
# Find out what directory the file is in.
# Also, remove the parth of the path that is $wmldir
indir=`dirname $file`
@@ -84,6 +98,13 @@
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"
@@ -95,11 +116,21 @@
fi
fi
- # Did the po file exist prior to running this script?
- # If not, po4a-gettextize will create it.
+ # Check to see if the po 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"
+ done
else
poexist=0
fi
@@ -161,6 +192,15 @@
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
done
# Commit the files