Modify update script to use current location

This commit is contained in:
Seth Hillbrand 2020-10-20 14:38:08 -07:00
parent e497639320
commit ad421fded8
1 changed files with 17 additions and 13 deletions

View File

@ -13,7 +13,7 @@
export LC_ALL=C export LC_ALL=C
display_help() { display_help() {
echo "Usage: $0 [-k] [-p] [locale]" echo "Usage: $0 [-k] [-p] [-s=<path>] <locale|all>"
echo " -k keep pot template and not delete it" echo " -k keep pot template and not delete it"
echo " -p plot the translation statistics [requires python with matplotlib]" echo " -p plot the translation statistics [requires python with matplotlib]"
echo " -s=<path> path to kicad source code" echo " -s=<path> path to kicad source code"
@ -45,8 +45,10 @@ case $i in
esac esac
done done
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -z ${SOURCEDIR} ]; then if [ -z ${SOURCEDIR} ]; then
SOURCEDIR=../kicad SOURCEDIR=${DIR}/..
echo "Using default SOURCEDIR=${SOURCEDIR}" echo "Using default SOURCEDIR=${SOURCEDIR}"
fi fi
@ -54,7 +56,6 @@ fi
cd $(dirname ${BASH_SOURCE[0]}) cd $(dirname ${BASH_SOURCE[0]})
LOCALDIR=$PWD LOCALDIR=$PWD
CSVFILE=${PWD}/i18n_status.csv CSVFILE=${PWD}/i18n_status.csv
LINGUAS=`cat $LOCALDIR/LINGUAS|grep -v '^#'|grep -v '^\s*$'` #Read file without comment and empty lines
POTDIRS=`cat $LOCALDIR/POTDIRS|grep -v '^#'|grep -v '^\s*$'` #Read file without comment and empty lines POTDIRS=`cat $LOCALDIR/POTDIRS|grep -v '^#'|grep -v '^\s*$'` #Read file without comment and empty lines
cd $SOURCEDIR cd $SOURCEDIR
@ -68,18 +69,21 @@ find $POTDIRS -name '*.cpp' -or -name '*.h' |
validate() { echo $LINGUAS | grep -F -q -w "$1"; } validate() { echo $LINGUAS | grep -F -q -w "$1"; }
#If supplied, update only the specified locale #If supplied, update only the specified locale
if [ ! "$SINGLE_LANG" = "" ] ; then if [ "$SINGLE_LANG" = "" ] ; then
if ! validate "$SINGLE_LANG"; then display_help
echo "Error!" elif [ "$SINGLE_LANG" = "all" ] ; then
echo "Locale argument \"$1\" not present in current locale list:" LINGUAS=`cat $LOCALDIR/LINGUAS|grep -v '^#'|grep -v '^\s*$'` #Read file without comment and empty lines
for i in $LINGUAS; do echo -n "$i "; done elif validate "$SINGLE_LANG"; then
echo # newline LINGUAS="$SINGLE_LANG"
exit 1 else
else echo "Error!"
LINGUAS="$SINGLE_LANG" echo "Locale argument \"$1\" not present in current locale list:"
fi for i in $LINGUAS; do echo -n "$i "; done
echo # newline
exit 1
fi fi
echo "Writing summary to ${CSVFILE}" echo "Writing summary to ${CSVFILE}"
echo "LANG;TRANSLATED;FUZZY;UNTRANSLATED" > "${CSVFILE}" echo "LANG;TRANSLATED;FUZZY;UNTRANSLATED" > "${CSVFILE}"