Add -s|--silent option to suppress msgmerge output.
This commit is contained in:
parent
f27a10aeea
commit
ef8cd63cd2
|
@ -1,6 +1,7 @@
|
|||
l#!/bin/bash
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2007, Donatas Glodenis <dgvirtual@akl.lt>
|
||||
# Copyright 2009, Andrius Štikonas <stikonas@gmail.com>
|
||||
#
|
||||
# #
|
||||
# # This script is free software; you can redistribute it and/or modify
|
||||
|
@ -28,6 +29,7 @@ function usage() {
|
|||
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"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -39,6 +41,10 @@ do
|
|||
option_new_as_primary="Y"
|
||||
shift
|
||||
;;
|
||||
-s|--silent)
|
||||
option_silent="Y"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
usage
|
||||
;;
|
||||
|
@ -58,15 +64,24 @@ upddir=$1
|
|||
tradir=$2
|
||||
tpldir=$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`
|
||||
skipped_files=0
|
||||
merged_files=0
|
||||
echo -ne "\r$merged_files/$total_files merged"
|
||||
fi
|
||||
newtrans=`cd $upddir; find . -name "*.po"`
|
||||
if [ "$newtrans" == "" ]; then
|
||||
echo " ... no updated files found in: $upddir"
|
||||
exit 1
|
||||
else
|
||||
if [ ! "$option_silent" = "Y" ]; then
|
||||
echo " ... they are."
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
## PAGRINDINIS CIKLAS
|
||||
for updfile in $newtrans
|
||||
|
@ -93,10 +108,14 @@ if [ `cd $tradir; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then
|
|||
fi
|
||||
|
||||
if [ `cd $tpldir; 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,"
|
||||
echo "SKIPPING..."
|
||||
find ${updfile}t -print
|
||||
else
|
||||
skipped_files=$(($skipped_files+1))
|
||||
fi
|
||||
continue
|
||||
# o gal ir ne taip daroma
|
||||
fi
|
||||
|
@ -117,17 +136,37 @@ fi
|
|||
mv $tradir/$trafile $tradir/${trafile}.old
|
||||
|
||||
if [ "$option_new_as_primary" = "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
|
||||
else
|
||||
msgmerge -N -v --compendium=$tradir/${trafile}.old -o $tradir/${trafile}.new $upddir/$updfile $tpldir/$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
|
||||
else
|
||||
msgmerge -N -v --compendium=$upddir/$updfile -o $tradir/${trafile}.new $tradir/${trafile}.old $tpldir/$tplfile 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
cat $tradir/${trafile}.new | sed '/X-Rosetta-Export-Date/d' > $tradir/$trafile
|
||||
rm $tradir/${trafile}.new
|
||||
rm $tradir/${trafile}.old
|
||||
|
||||
if [ "$option_silent" = "Y" ]; then
|
||||
merged_files=$(($merged_files+1))
|
||||
echo -ne "\r$merged_files/$total_files merged"
|
||||
if [ ! $skipped_files -eq 0 ]; then
|
||||
echo -ne ", $skipped_files skipped"
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [ "$option_silent" = "Y" ]; then
|
||||
echo
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue