added CHANGELOG and modified ths-poupdate.sh (switch in the case which file (new or old) is used as a default translation)

This commit is contained in:
Donatas G 2009-02-15 15:47:09 +02:00
parent 72ee866c01
commit 3773c6e808
2 changed files with 45 additions and 31 deletions

14
CHANGELOG Normal file
View File

@ -0,0 +1,14 @@
CHANGELOG
==== TODO ===
* ths-poupdate.sh - add a function to allow cleanup of a file to be updated of the fuzzy strings (this will allow the file to be updated to be translated including the strings that were old).
=== /TODO ===
v. 0.3 (2009-xx-xx)
* ths-poupdate.sh - changed the default from using the old translation as primary to using the new translation as primary.
v. 0.2 (2008-01-18)
* updated ths-applysed.sh command, removed a serious flaw that would at times eat half a file where it should not have.
v. 0.1 (2007-09-17)
* initial release.

View File

@ -26,10 +26,10 @@ function usage() {
echo "Usage `basename $0` [options] <updated-file-dir> <translations-file-tree> <translations-template-tree>" echo "Usage `basename $0` [options] <updated-file-dir> <translations-file-tree> <translations-template-tree>"
echo echo
echo "Options:" echo "Options:"
echo " -P|--new-as-primary - use newly translated file translations" echo " -NS|--new-as-secondary - use newly translated file translations"
echo " as primary (default - use the new files" echo " as secondary (default - use the new files"
echo " as secondary translations)" echo " as primary translations)"
echo " -s|--silent - suppress msgmerge output" echo " -s|--silent - suppress msgmerge output"
exit 1 exit 1
} }
@ -37,8 +37,8 @@ function usage() {
while true while true
do do
case $1 in case $1 in
-P|--new-as-primary) -NS|--new-as-secondary)
option_new_as_primary="Y" option_new_as_secondary="Y"
shift shift
;; ;;
-s|--silent) -s|--silent)
@ -60,21 +60,21 @@ if [ $# -ne 3 ]; then
fi fi
## Change paths to variables ## Change paths to variables
upddir=$1 upd_dir=$1
tradir=$2 tra_tree=$2
tpldir=$3 tpl_tree=$3
if [ ! "$option_silent" = "Y" ]; then if [ ! "$option_silent" = "Y" ]; then
echo "Checking if updated files are in the specified directory ..." echo "Checking if updated files are in the specified directory ..."
else else
total_files=`find $upddir -name "*.po" | wc -l` total_files=`find $upd_dir -name "*.po" | wc -l`
skipped_files=0 skipped_files=0
merged_files=0 merged_files=0
echo -ne "\r$merged_files/$total_files merged" echo -ne "\r$merged_files/$total_files merged"
fi fi
newtrans=`cd $upddir; find . -name "*.po"` newtrans=`cd $upd_dir; find . -name "*.po"`
if [ "$newtrans" == "" ]; then if [ "$newtrans" == "" ]; then
echo " ... no updated files found in: $upddir" echo " ... no updated files found in: $upd_dir"
exit 1 exit 1
else else
if [ ! "$option_silent" = "Y" ]; then if [ ! "$option_silent" = "Y" ]; then
@ -87,7 +87,7 @@ fi
for updfile in $newtrans for updfile in $newtrans
do do
if [ `cd $tpldir; find ${updfile}t 2> /dev/null | wc -l` -gt 1 ]; then if [ `cd $tpl_tree; find ${updfile}t 2> /dev/null | wc -l` -gt 1 ]; then
echo echo
echo "Strange, there is more than one template for `basename $updfile`," echo "Strange, there is more than one template for `basename $updfile`,"
echo "cannot determine the right one," echo "cannot determine the right one,"
@ -95,7 +95,7 @@ if [ `cd $tpldir; find ${updfile}t 2> /dev/null | wc -l` -gt 1 ]; then
continue continue
fi fi
if [ `cd $tradir; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then if [ `cd $tra_tree; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then
echo echo
echo "Strange, there is more than one version of translation `basename $updfile`," echo "Strange, there is more than one version of translation `basename $updfile`,"
echo "although there is only one translation template. There might be an extra" echo "although there is only one translation template. There might be an extra"
@ -105,7 +105,7 @@ if [ `cd $tradir; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then
continue continue
fi fi
if [ `cd $tpldir; find ${updfile}t 2> /dev/null | wc -l` -lt 1 ]; then if [ `cd $tpl_tree; find ${updfile}t 2> /dev/null | wc -l` -lt 1 ]; then
if [ ! "$option_silent" = "Y" ]; then if [ ! "$option_silent" = "Y" ]; then
echo echo
echo "File `basename $updfile` does not belong to this translation project," echo "File `basename $updfile` does not belong to this translation project,"
@ -118,43 +118,43 @@ if [ `cd $tpldir; find ${updfile}t 2> /dev/null | wc -l` -lt 1 ]; then
fi fi
if [ `cd $tradir; find ${updfile} 2> /dev/null | wc -l` -lt 1 ]; then if [ `cd $tra_tree; find ${updfile} 2> /dev/null | wc -l` -lt 1 ]; then
echo echo
echo "File `basename $updfile` is completely newly translated," echo "File `basename $updfile` is completely newly translated,"
echo "COPYING it to the appropriate place..." echo "COPYING it to the appropriate place..."
#finding the appropriate #finding the appropriate
tplfile=`cd $tpldir; find ${updfile}t` tplfile=`cd $tpl_tree; find ${updfile}t`
secdir=`dirname $tplfile` secdir=`dirname $tplfile`
cp $upddir/$updfile $tradir/$secdir/$updfile cp $upd_dir/$updfile $tra_tree/$secdir/$updfile
fi fi
# perform msgmerge and other actions # perform msgmerge and other actions
trafile=`cd $tradir; find $updfile` trafile=`cd $tra_tree; find $updfile`
tplfile=`cd $tpldir; find ${updfile}t` tplfile=`cd $tpl_tree; find ${updfile}t`
mv $tradir/$trafile $tradir/${trafile}.old mv $tra_tree/$trafile $tra_tree/${trafile}.old
if [ "$option_new_as_primary" = "Y" ]; then if [ ! "$option_new_as_secondary" = "Y" ]; then
if [ ! "$option_silent" = "Y" ]; then if [ ! "$option_silent" = "Y" ]; then
echo echo
echo "UPDATING $trafile using translations from $upddir/$updfile as PRIMARY translations" echo "UPDATING $trafile using translations from $upd_dir/$updfile as SECONDARY translations"
msgmerge -N -v --compendium=$tradir/${trafile}.old -o $tradir/${trafile}.new $upddir/$updfile $tpldir/$tplfile msgmerge -N -v --compendium=$upd_dir/$updfile -o $tra_tree/${trafile}.new $tra_tree/${trafile}.old $tpl_tree/$tplfile
else else
msgmerge -N -v --compendium=$tradir/${trafile}.old -o $tradir/${trafile}.new $upddir/$updfile $tpldir/$tplfile 2> /dev/null msgmerge -N -v --compendium=$upd_dir/$updfile -o $tra_tree/${trafile}.new $tra_tree/${trafile}.old $tpl_tree/$tplfile 2> /dev/null
fi fi
else else
if [ ! "$option_silent" = "Y" ]; then if [ ! "$option_silent" = "Y" ]; then
echo echo
echo "UPDATING $trafile using translations from $upddir/$updfile as SECONDARY translations" echo "UPDATING $trafile using translations from $upd_dir/$updfile as PRIMARY translations"
msgmerge -N -v --compendium=$upddir/$updfile -o $tradir/${trafile}.new $tradir/${trafile}.old $tpldir/$tplfile msgmerge -N -v --compendium=$tra_tree/${trafile}.old -o $tra_tree/${trafile}.new $upd_dir/$updfile $tpl_tree/$tplfile
else else
msgmerge -N -v --compendium=$upddir/$updfile -o $tradir/${trafile}.new $tradir/${trafile}.old $tpldir/$tplfile 2> /dev/null msgmerge -N -v --compendium=$tra_tree/${trafile}.old -o $tra_tree/${trafile}.new $upd_dir/$updfile $tpl_tree/$tplfile 2> /dev/null
fi fi
fi fi
# delete the Rosetta/Launchpad headers, only needed if the file was imported from Rosetta # delete the Rosetta/Launchpad headers, only needed if the file was imported from Rosetta
cat $tradir/${trafile}.new | sed '/X-Rosetta-Export-Date/d' > $tradir/$trafile cat $tra_tree/${trafile}.new | sed '/X-Rosetta-Export-Date/d' > $tra_tree/$trafile
rm $tradir/${trafile}.new rm $tra_tree/${trafile}.new
rm $tradir/${trafile}.old rm $tra_tree/${trafile}.old
if [ "$option_silent" = "Y" ]; then if [ "$option_silent" = "Y" ]; then
merged_files=$(($merged_files+1)) merged_files=$(($merged_files+1))