Browse Source

Merge branch 'donato'

master
Donatas G 13 years ago
parent
commit
e64925c6f1
  1. 14
      CHANGELOG
  2. 62
      ths-poupdate.sh

14
CHANGELOG

@ -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.

62
ths-poupdate.sh

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

Loading…
Cancel
Save