Add runtime checks for dependencies.

This commit is contained in:
Andrius Štikonas 2009-02-15 21:50:44 +02:00
parent 705e6f4d3d
commit 329e7b5a25
7 changed files with 120 additions and 26 deletions

View File

@ -18,6 +18,19 @@
# #
# ths-autotranslate.sh - automatically translates project files (may initialize files that have not been started to translate) using a specified compendium. # ths-autotranslate.sh - automatically translates project files (may initialize files that have not been started to translate) using a specified compendium.
source ths-variables
if [ ! $MSGINIT ]; then
echo -e $RED"This program needs the msginit utility."$ENDCOLOR
exit 1
fi
if [ ! $MSGMERGE ]; then
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
exit 1
fi
function usage() { function usage() {
echo "Usage `basename $0` [options] <translation-files> <template-files>" echo "Usage `basename $0` [options] <translation-files> <template-files>"
echo echo
@ -110,9 +123,9 @@ else
echo echo
else else
if [ ! $option_verbose ]; then if [ ! $option_verbose ]; then
msginit $option_no_wrap --locale=$option_locale --no-translator -i $templates/$pot -o $new/$directory/$filename 2>&1 | egrep -v "^Created" $MSGINIT $option_no_wrap --locale=$option_locale --no-translator -i $templates/$pot -o $new/$directory/$filename 2>&1 | egrep -v "^Created"
else else
msginit $option_no_wrap --locale=$option_locale --no-translator -i $templates/$pot -o $new/$directory/$filename $MSGINIT $option_no_wrap --locale=$option_locale --no-translator -i $templates/$pot -o $new/$directory/$filename
fi fi
fi fi
@ -123,5 +136,5 @@ echo "** Updating files against templates (optionally with compendium)... **"
for po in `cd $new ; find . -name "*.po" | sort` for po in `cd $new ; find . -name "*.po" | sort`
do do
[ $option_verbose ] && echo -n $new/$po [ $option_verbose ] && echo -n $new/$po
msgmerge $option_verbose_msgmerge $option_no_fuzzy_matching $option_no_wrap $option_use_own_compendium --backup=off --update $new/$po $templates/${po}t $MSGMERGE $option_verbose_msgmerge $option_no_fuzzy_matching $option_no_wrap $option_use_own_compendium --backup=off --update $new/$po $templates/${po}t
done done

View File

@ -19,6 +19,18 @@
# ths-pocompare.sh - compare two translation files using diff, unwrapps first # ths-pocompare.sh - compare two translation files using diff, unwrapps first
# for best comparison. # for best comparison.
source ths-variables
if [ ! $MSGMERGE ]; then
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
exit 1
fi
if [ ! $DIFF ]; then
echo -e $RED"This program needs the diff utility."$ENDCOLOR
exit 1
fi
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo "Usage `basename $0` <file1> <file2>" echo "Usage `basename $0` <file1> <file2>"
exit 1 exit 1
@ -27,10 +39,7 @@ fi
file1=$1 file1=$1
file2=$2 file2=$2
msgmerge --no-wrap $file1 $file1 -o ${file1}.for.diff $MSGMERGE --no-wrap $file1 $file1 -o ${file1}.for.diff
$MSGMERGE --no-wrap $file2 $file2 -o ${file2}.for.diff
msgmerge --no-wrap $file2 $file2 -o ${file2}.for.diff $DIFF ${file1}.for.diff ${file2}.for.diff
diff ${file1}.for.diff ${file2}.for.diff
rm ${file1}.for.diff ${file2}.for.diff rm ${file1}.for.diff ${file2}.for.diff

View File

@ -19,6 +19,18 @@
# ths-pocompare-kdiff3.sh - compare two translation files using kdiff3, # ths-pocompare-kdiff3.sh - compare two translation files using kdiff3,
# unwrapps first for best comparison. # unwrapps first for best comparison.
source ths-variables
if [ ! $MSGMERGE ]; then
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
exit 1
fi
if [ ! $KDIFF3 ]; then
echo -e $RED"This program needs the kdiff3 utility."$ENDCOLOR
exit 1
fi
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo "Usage `basename $0` <file1> <file2>" echo "Usage `basename $0` <file1> <file2>"
exit 1 exit 1
@ -27,10 +39,7 @@ fi
file1=$1 file1=$1
file2=$2 file2=$2
msgmerge --no-wrap $file1 $file1 -o ${file1}.for.diff $MSGMERGE --no-wrap $file1 $file1 -o ${file1}.for.diff
$MSGMERGE --no-wrap $file2 $file2 -o ${file2}.for.diff
msgmerge --no-wrap $file2 $file2 -o ${file2}.for.diff $KDIFF3 ${file1}.for.diff ${file2}.for.diff
rm ${file1}.for.diff ${file2}.for.diff
kdiff3 ${file1}.for.diff ${file2}.for.diff
rm ${file1}.for.diff ${file2}.for.diff

16
potopot
View File

@ -19,6 +19,18 @@
# ths-potopot.sh - converts po files to pot (template) files (basically # ths-potopot.sh - converts po files to pot (template) files (basically
# strips all the translation). # strips all the translation).
source ths-variables
if [ ! $MSGMERGE ]; then
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
exit 1
fi
if [ ! $MSGFILTER ]; then
echo -e $RED"This program needs the msgfilter utility."$ENDCOLOR
exit 1
fi
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
echo "Usage: `basename $0` </directory/with/pofiles/>" echo "Usage: `basename $0` </directory/with/pofiles/>"
exit 1 exit 1
@ -40,10 +52,10 @@ for file in `cd $pofiles; find . -name "*.po"`
do do
echo -n "Working on ${file}. Unwrapping..." echo -n "Working on ${file}. Unwrapping..."
# unwrap messages for cleaner operation # unwrap messages for cleaner operation
msgmerge --no-wrap ${pofiles}/$file $pofiles/$file -o $pofiles/$file $MSGMERGE --no-wrap ${pofiles}/$file $pofiles/$file -o $pofiles/$file
# remove the translations and creating pot files # remove the translations and creating pot files
echo "Cleaning up translations..." echo "Cleaning up translations..."
msgfilter --input=$pofiles/$file --output-file=$pofiles/templates/${file}t --keep-header sed --expression='s/.*//' ; echo "done." $MSGFILTER --input=$pofiles/$file --output-file=$pofiles/templates/${file}t --keep-header sed --expression='s/.*//' ; echo "done."
# applying some more filters via sed: remove remaining \n signs (sed 1 and 2), removing the fuzzy headers (3), removing the empty "" (4), removing the extra empty lines (5) # applying some more filters via sed: remove remaining \n signs (sed 1 and 2), removing the fuzzy headers (3), removing the empty "" (4), removing the extra empty lines (5)
echo "Applying additional filter..." echo "Applying additional filter..."
cat $pofiles/templates/${file}t | sed -e 's/msgstr \"\\n\"/msgstr \"\"/' | \ cat $pofiles/templates/${file}t | sed -e 's/msgstr \"\\n\"/msgstr \"\"/' | \

View File

@ -17,10 +17,18 @@
# # along with this script; if not, write to the Free Software # # along with this script; if not, write to the Free Software
# # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# ths-poupdate.sh - takes a bunch of files from a single directory and transfers the translations therein to a translation file tree; may use the new files either as primary, or as secondary translations. # ths-poupdate.sh - takes a bunch of files from a single directory and transfers the translations therein to a translation file tree;
# may use the new files either as primary, or as secondary translations.
## First - the necessary checks before going into the loop ## First - the necessary checks before going into the loop
source ths-variables
if [ ! $MSGMERGE ]; then
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
exit 1
fi
## 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>"
@ -33,7 +41,7 @@ function usage() {
exit 1 exit 1
} }
## PARAMETRAI ## OPTIONS
while true while true
do do
case $1 in case $1 in
@ -137,17 +145,17 @@ 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

View File

@ -18,6 +18,18 @@
# #
# ths-stripfuzzy.sh - makes all fuzzy strings non-fuzzy in a translation project. # ths-stripfuzzy.sh - makes all fuzzy strings non-fuzzy in a translation project.
source ths-variables
if [ ! $MSGMERGE ]; then
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
exit 1
fi
if [ ! $MSGATTRIB ]; then
echo -e $RED"This program needs the msgattrib utility."$ENDCOLOR
exit 1
fi
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo "Usage `basename $0` <pofile directory> <templates directory>" echo "Usage `basename $0` <pofile directory> <templates directory>"
exit 1 exit 1
@ -30,7 +42,7 @@ echo "Completely removing the fuzzy strings from the pofiles..."
for po in `cd $pofiles ; find . -name "*.po"` for po in `cd $pofiles ; find . -name "*.po"`
do do
echo -n $pofiles/$po echo -n $pofiles/$po
msgattrib -o $pofiles/$po --no-fuzzy $pofiles/$po $MSGATTRIB -o $pofiles/$po --no-fuzzy $pofiles/$po
done done
@ -38,5 +50,5 @@ echo "Restoring the previously fuzzy as untranslated strings..."
for po in `cd $pofiles ; find . -name "*.po"` for po in `cd $pofiles ; find . -name "*.po"`
do do
echo -n $pofiles/$po echo -n $pofiles/$po
msgmerge --no-fuzzy-matching --backup=off --update $pofiles/$po $templates/${po}t $MSGMERGE --no-fuzzy-matching --backup=off --update $pofiles/$po $templates/${po}t
done done

31
ths-variables Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# You would probably need to make some adjustments to variables.
# Copyright (C) 2009 Andrius Štikonas <stikonas@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#Binaries
DIFF=`which diff 2> /dev/null`
MSGATTRIB=`which msgattrib 2> /dev/null`
MSGFILTER=`which msgfilter 2> /dev/null`
MSGFMT=`which msgfmt 2> /dev/null`
MSGINIT=`which msginit 2> /dev/null`
MSGMERGE=`which msgmerg1e 2> /dev/null`
KDIFF3=`which kdiff3 2> /dev/null`
#Colors
RED="\033[1;31m"
GREEN="\033[1;32m"
BLUE="\033[1;34m"
ENDCOLOR="\033[0m"