shellcheck fixes.
This commit is contained in:
parent
fd74ecaa95
commit
bba53c12f1
73
poupdate
73
poupdate
|
@ -22,11 +22,11 @@
|
|||
|
||||
## First - the necessary checks before going into the loop
|
||||
|
||||
source "`dirname $0`/ths-variables"
|
||||
source "$(dirname "$0")/ths-variables"
|
||||
|
||||
## Declaring Functions
|
||||
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 "Options:"
|
||||
echo " -NS|--new-as-secondary - use newly translated file translations"
|
||||
|
@ -53,7 +53,7 @@ do
|
|||
option_silent="Y"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
-*)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
|
@ -72,8 +72,8 @@ upd_dir=$1
|
|||
tra_tree=$2
|
||||
tpl_tree=$3
|
||||
|
||||
newtrans=`cd $upd_dir; find . -name "*.po"`
|
||||
total_files=`echo $newtrans | wc -w`
|
||||
newtrans=$(cd "$upd_dir" || exit; find . -name "*.po")
|
||||
total_files=$(echo "$newtrans" | wc -w)
|
||||
skipped_files=0
|
||||
processed_files=0
|
||||
changed_files=0
|
||||
|
@ -85,7 +85,7 @@ elif [ ! "$option_silent" = "Y" ]; then
|
|||
echo -ne "\r$processed_files/$total_files processed"
|
||||
fi
|
||||
if [ "$newtrans" == "" ]; then
|
||||
echo -e $RED"\t\t... no updated files found in: $upd_dir"$ENDCOLOR
|
||||
echo -e "${RED}\t\t... no updated files found in: $upd_dir$ENDCOLOR"
|
||||
exit 1
|
||||
else
|
||||
if [ "$option_verbose" = "Y" ]; then
|
||||
|
@ -97,20 +97,20 @@ fi
|
|||
## MAIN LOOP
|
||||
for updfile in $newtrans
|
||||
do
|
||||
if [ `cd "$tpl_tree"; 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
|
||||
if [ "$option_verbose" = "Y" ]; then
|
||||
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 "SKIPPING..."
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ `cd "$tpl_tree"; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then
|
||||
if [ "$(cd "$tpl_tree"; find "${updfile}" 2> /dev/null | wc -l)" -gt 1 ]; then
|
||||
if [ "$option_verbose" = "Y" ]; then
|
||||
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 "unneeded file in your translation tree, check it out!"
|
||||
echo "Cannot determine the right file to translate,"
|
||||
|
@ -119,69 +119,64 @@ if [ `cd "$tpl_tree"; find ${updfile} 2> /dev/null | wc -l` -gt 1 ]; then
|
|||
continue
|
||||
fi
|
||||
|
||||
if [ `cd $tpl_tree; 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_verbose" = "Y" ]; then
|
||||
echo
|
||||
echo -e "File $RED`basename "$updfile"`$ENDCOLOR does not belong to this translation project,"
|
||||
echo -e "File $RED$(basename "$updfile")$ENDCOLOR does not belong to this translation project,"
|
||||
echo "SKIPPING..."
|
||||
find ${updfile}t -print
|
||||
find "${updfile}t" -print
|
||||
fi
|
||||
skipped_files=$(($skipped_files+1))
|
||||
processed_files=$(($processed_files+1))
|
||||
skipped_files=$((skipped_files+1))
|
||||
processed_files=$((processed_files+1))
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ `cd "$tra_tree"; 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 -e "File $RED`basename $updfile`$ENDCOLOR is completely newly translated,"
|
||||
echo -e "File $RED$(basename "$updfile")$ENDCOLOR is completely newly translated,"
|
||||
echo "COPYING it to the appropriate place..."
|
||||
#finding the appropriate
|
||||
tplfile=`cd "$tpl_tree"; find ${updfile}t`
|
||||
secdir=`dirname "$tplfile"`
|
||||
tplfile=$(cd "$tpl_tree" || exit; find "$updfile"t)
|
||||
cp "$upd_dir/$updfile" "$tra_tree/$updfile"
|
||||
if [ svn ]; then
|
||||
svn add "$tra_tree/$updfile"
|
||||
fi
|
||||
fi
|
||||
|
||||
# perform msgmerge and other actions
|
||||
trafile=`cd "$tra_tree"; find "$updfile"`
|
||||
tplfile=`cd "$tpl_tree"; find "${updfile}t"`
|
||||
trafile=$(cd "$tra_tree" || exit; find "$updfile")
|
||||
tplfile=$(cd "$tpl_tree" || exit; find "${updfile}t")
|
||||
mv "$tra_tree/$trafile" "$tra_tree/${trafile}.old"
|
||||
|
||||
if [ ! "$option_new_as_secondary" = "Y" ]; then
|
||||
if [ "$option_verbose" = "Y" ]; then
|
||||
echo
|
||||
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
|
||||
msgmerge -N -v --compendium="$upd_dir/$updfile" -o "$tra_tree/$trafile.new" "$tra_tree/${trafile}.old" "$tpl_tree/$tplfile"
|
||||
else
|
||||
msgmerge -N -v --compendium=$upd_dir/$updfile -o $tra_tree/${trafile}.new $tra_tree/${trafile}.old $tpl_tree/$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_verbose" = "Y" ]; then
|
||||
echo
|
||||
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
|
||||
msgmerge -N -v --compendium="$tra_tree/$trafile.old" -o "$tra_tree/$trafile.new" "$upd_dir/$updfile" "$tpl_tree/$tplfile"
|
||||
else
|
||||
msgmerge -N -v --compendium=$tra_tree/${trafile}.old -o $tra_tree/${trafile}.new $upd_dir/$updfile $tpl_tree/$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 $tra_tree/${trafile}.new | sed '/X-Rosetta-Export-Date/d' > $tra_tree/$trafile
|
||||
sed '/X-Rosetta-Export-Date/d' < "$tra_tree/$trafile.new" > "$tra_tree/$trafile"
|
||||
|
||||
if [ $diff ]; then
|
||||
if [ "`$diff $tra_tree/${trafile}.old $tra_tree/${trafile}.new`" ]; then
|
||||
changed_files=$(($changed_files+1))
|
||||
fi
|
||||
if [ "$(diff "$tra_tree/$trafile.old" "$tra_tree/$trafile.new")" ]; then
|
||||
changed_files=$((changed_files+1))
|
||||
fi
|
||||
|
||||
rm $tra_tree/${trafile}.old $tra_tree/${trafile}.new
|
||||
rm "$tra_tree/$trafile.old" "$tra_tree/$trafile.new"
|
||||
|
||||
processed_files=$(($processed_files+1))
|
||||
processed_files=$((processed_files+1))
|
||||
if [ ! "$option_verbose" = "Y" ] && [ ! "$option_silent" = "Y" ]; then
|
||||
echo -ne "\r$processed_files/$total_files processed"
|
||||
if [ $diff ] && [ ! $changed_files -eq 0 ]; then
|
||||
if [ ! $changed_files -eq 0 ]; then
|
||||
echo -ne ", $changed_files changed"
|
||||
fi
|
||||
if [ ! $skipped_files -eq 0 ]; then
|
||||
|
@ -191,12 +186,12 @@ fi
|
|||
|
||||
done
|
||||
|
||||
echo -ne $BLUE"\r$processed_files/$total_files processed"$ENDCOLOR
|
||||
if [ $diff ] && [ ! $changed_files -eq 0 ]; then
|
||||
echo -ne $BLUE", $changed_files changed"$ENDCOLOR
|
||||
echo -ne "$BLUE\r$processed_files/$total_files processed$ENDCOLOR"
|
||||
if [ ! "$changed_files" -eq 0 ]; then
|
||||
echo -ne "$BLUE, $changed_files changed$ENDCOLOR"
|
||||
fi
|
||||
|
||||
if [ ! $skipped_files -eq 0 ]; then
|
||||
echo -ne $BLUE", $skipped_files skipped"$ENDCOLOR
|
||||
echo -ne "$BLUE, $skipped_files skipped$ENDCOLOR"
|
||||
fi
|
||||
echo
|
||||
|
|
Loading…
Reference in New Issue