Browse Source

Add runtime checks for dependencies.

master
Andrius Štikonas 13 years ago
parent
commit
329e7b5a25
  1. 19
      autotranslate
  2. 21
      pocompare
  3. 23
      pocompare-kdiff3
  4. 16
      potopot
  5. 20
      poupdate
  6. 16
      stripfuzzy
  7. 31
      ths-variables

19
autotranslate

@ -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.
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() {
echo "Usage `basename $0` [options] <translation-files> <template-files>"
echo
@ -110,9 +123,9 @@ else
echo
else
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
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
@ -123,5 +136,5 @@ echo "** Updating files against templates (optionally with compendium)... **"
for po in `cd $new ; find . -name "*.po" | sort`
do
[ $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

21
pocompare

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

23
pocompare-kdiff3

@ -19,6 +19,18 @@
# ths-pocompare-kdiff3.sh - compare two translation files using kdiff3,
# 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
echo "Usage `basename $0` <file1> <file2>"
exit 1
@ -27,10 +39,7 @@ fi
file1=$1
file2=$2
msgmerge --no-wrap $file1 $file1 -o ${file1}.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
$MSGMERGE --no-wrap $file1 $file1 -o ${file1}.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

16
potopot

@ -19,6 +19,18 @@
# ths-potopot.sh - converts po files to pot (template) files (basically
# 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
echo "Usage: `basename $0` </directory/with/pofiles/>"
exit 1
@ -40,10 +52,10 @@ for file in `cd $pofiles; find . -name "*.po"`
do
echo -n "Working on ${file}. Unwrapping..."
# 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
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)
echo "Applying additional filter..."
cat $pofiles/templates/${file}t | sed -e 's/msgstr \"\\n\"/msgstr \"\"/' | \

20
poupdate

@ -17,10 +17,18 @@
# # along with this script; if not, write to the Free Software
# # 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
source ths-variables
if [ ! $MSGMERGE ]; then
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
exit 1
fi
## Declaring Functions
function usage() {
echo "Usage `basename $0` [options] <updated-file-dir> <translations-file-tree> <translations-template-tree>"
@ -33,7 +41,7 @@ function usage() {
exit 1
}
## PARAMETRAI
## OPTIONS
while true
do
case $1 in
@ -137,17 +145,17 @@ 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

16
stripfuzzy

@ -18,6 +18,18 @@
#
# 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
echo "Usage `basename $0` <pofile directory> <templates directory>"
exit 1
@ -30,7 +42,7 @@ echo "Completely removing the fuzzy strings from the pofiles..."
for po in `cd $pofiles ; find . -name "*.po"`
do
echo -n $pofiles/$po
msgattrib -o $pofiles/$po --no-fuzzy $pofiles/$po
$MSGATTRIB -o $pofiles/$po --no-fuzzy $pofiles/$po
done
@ -38,5 +50,5 @@ echo "Restoring the previously fuzzy as untranslated strings..."
for po in `cd $pofiles ; find . -name "*.po"`
do
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

31
ths-variables

@ -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"
Loading…
Cancel
Save