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
|
## First - the necessary checks before going into the loop
|
||||||
|
|
||||||
source "`dirname $0`/ths-variables"
|
source "$(dirname "$0")/ths-variables"
|
||||||
|
|
||||||
## Declaring Functions
|
## Declaring Functions
|
||||||
function usage() {
|
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 " -NS|--new-as-secondary - use newly translated file translations"
|
echo " -NS|--new-as-secondary - use newly translated file translations"
|
||||||
|
@ -53,7 +53,7 @@ do
|
||||||
option_silent="Y"
|
option_silent="Y"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-*|--*)
|
-*)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -72,8 +72,8 @@ upd_dir=$1
|
||||||
tra_tree=$2
|
tra_tree=$2
|
||||||
tpl_tree=$3
|
tpl_tree=$3
|
||||||
|
|
||||||
newtrans=`cd $upd_dir; find . -name "*.po"`
|
newtrans=$(cd "$upd_dir" || exit; find . -name "*.po")
|
||||||
total_files=`echo $newtrans | wc -w`
|
total_files=$(echo "$newtrans" | wc -w)
|
||||||
skipped_files=0
|
skipped_files=0
|
||||||
processed_files=0
|
processed_files=0
|
||||||
changed_files=0
|
changed_files=0
|
||||||
|
@ -85,7 +85,7 @@ elif [ ! "$option_silent" = "Y" ]; then
|
||||||
echo -ne "\r$processed_files/$total_files processed"
|
echo -ne "\r$processed_files/$total_files processed"
|
||||||
fi
|
fi
|
||||||
if [ "$newtrans" == "" ]; then
|
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
|
exit 1
|
||||||
else
|
else
|
||||||
if [ "$option_verbose" = "Y" ]; then
|
if [ "$option_verbose" = "Y" ]; then
|
||||||
|
@ -97,20 +97,20 @@ fi
|
||||||
## MAIN LOOP
|
## MAIN LOOP
|
||||||
for updfile in $newtrans
|
for updfile in $newtrans
|
||||||
do
|
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
|
if [ "$option_verbose" = "Y" ]; 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,"
|
||||||
echo "SKIPPING..."
|
echo "SKIPPING..."
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
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
|
if [ "$option_verbose" = "Y" ]; 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"
|
||||||
echo "unneeded file in your translation tree, check it out!"
|
echo "unneeded file in your translation tree, check it out!"
|
||||||
echo "Cannot determine the right file to translate,"
|
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
|
continue
|
||||||
fi
|
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
|
if [ "$option_verbose" = "Y" ]; then
|
||||||
echo
|
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..."
|
echo "SKIPPING..."
|
||||||
find ${updfile}t -print
|
find "${updfile}t" -print
|
||||||
fi
|
fi
|
||||||
skipped_files=$(($skipped_files+1))
|
skipped_files=$((skipped_files+1))
|
||||||
processed_files=$(($processed_files+1))
|
processed_files=$((processed_files+1))
|
||||||
continue
|
continue
|
||||||
fi
|
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
|
||||||
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..."
|
echo "COPYING it to the appropriate place..."
|
||||||
#finding the appropriate
|
#finding the appropriate
|
||||||
tplfile=`cd "$tpl_tree"; find ${updfile}t`
|
tplfile=$(cd "$tpl_tree" || exit; find "$updfile"t)
|
||||||
secdir=`dirname "$tplfile"`
|
|
||||||
cp "$upd_dir/$updfile" "$tra_tree/$updfile"
|
cp "$upd_dir/$updfile" "$tra_tree/$updfile"
|
||||||
if [ svn ]; then
|
|
||||||
svn add "$tra_tree/$updfile"
|
svn add "$tra_tree/$updfile"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# perform msgmerge and other actions
|
# perform msgmerge and other actions
|
||||||
trafile=`cd "$tra_tree"; find "$updfile"`
|
trafile=$(cd "$tra_tree" || exit; find "$updfile")
|
||||||
tplfile=`cd "$tpl_tree"; find "${updfile}t"`
|
tplfile=$(cd "$tpl_tree" || exit; find "${updfile}t")
|
||||||
mv "$tra_tree/$trafile" "$tra_tree/${trafile}.old"
|
mv "$tra_tree/$trafile" "$tra_tree/${trafile}.old"
|
||||||
|
|
||||||
if [ ! "$option_new_as_secondary" = "Y" ]; then
|
if [ ! "$option_new_as_secondary" = "Y" ]; then
|
||||||
if [ "$option_verbose" = "Y" ]; then
|
if [ "$option_verbose" = "Y" ]; then
|
||||||
echo
|
echo
|
||||||
echo "UPDATING $trafile using translations from $upd_dir/$updfile as SECONDARY translations"
|
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
|
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
|
fi
|
||||||
else
|
else
|
||||||
if [ "$option_verbose" = "Y" ]; then
|
if [ "$option_verbose" = "Y" ]; then
|
||||||
echo
|
echo
|
||||||
echo "UPDATING $trafile using translations from $upd_dir/$updfile as PRIMARY translations"
|
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
|
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
|
||||||
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 $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
|
||||||
if [ "`$diff $tra_tree/${trafile}.old $tra_tree/${trafile}.new`" ]; then
|
changed_files=$((changed_files+1))
|
||||||
changed_files=$(($changed_files+1))
|
|
||||||
fi
|
|
||||||
fi
|
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
|
if [ ! "$option_verbose" = "Y" ] && [ ! "$option_silent" = "Y" ]; then
|
||||||
echo -ne "\r$processed_files/$total_files processed"
|
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"
|
echo -ne ", $changed_files changed"
|
||||||
fi
|
fi
|
||||||
if [ ! $skipped_files -eq 0 ]; then
|
if [ ! $skipped_files -eq 0 ]; then
|
||||||
|
@ -191,12 +186,12 @@ fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -ne $BLUE"\r$processed_files/$total_files processed"$ENDCOLOR
|
echo -ne "$BLUE\r$processed_files/$total_files processed$ENDCOLOR"
|
||||||
if [ $diff ] && [ ! $changed_files -eq 0 ]; then
|
if [ ! "$changed_files" -eq 0 ]; then
|
||||||
echo -ne $BLUE", $changed_files changed"$ENDCOLOR
|
echo -ne "$BLUE, $changed_files changed$ENDCOLOR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $skipped_files -eq 0 ]; then
|
if [ ! $skipped_files -eq 0 ]; then
|
||||||
echo -ne $BLUE", $skipped_files skipped"$ENDCOLOR
|
echo -ne "$BLUE, $skipped_files skipped$ENDCOLOR"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
Loading…
Reference in New Issue