wesnoth-l10n-tools/update

107 lines
3.0 KiB
Plaintext
Raw Normal View History

2008-09-18 13:36:37 +01:00
#!/bin/bash
# Update translations from subversion repository and merge them
# Copyright (C) 2007-2008 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 3 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/>.
2009-05-18 11:49:35 +01:00
source "`dirname $0`/variables"
2008-09-18 13:36:37 +01:00
if [ ! $SVN ]; then
2008-11-11 09:57:24 +00:00
echo -e $RED"This program needs the svn utility."$ENDCOLOR
2008-09-18 13:36:37 +01:00
exit 1
fi
if [ ! $MSGFMT ]; then
2008-11-11 09:57:24 +00:00
echo -e $RED"This program needs the msgfmt utility."$ENDCOLOR
2008-09-18 13:36:37 +01:00
exit 1
fi
if [ ! $MSGMERGE ]; then
2008-11-11 09:57:24 +00:00
echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR
2008-09-18 13:36:37 +01:00
exit 1
fi
if [ ! $MSGINIT ]; then
2008-11-11 09:57:24 +00:00
echo -e $RED"This program needs the msginit utility."$ENDCOLOR
2008-09-18 13:36:37 +01:00
exit 1
fi
2008-11-11 09:57:24 +00:00
echo -e "Language: $RED$LCODE"$ENDCOLOR
2008-09-18 13:36:37 +01:00
echo ""
if [ ! -z $TRUNK ]; then
if [ -e $TRUNK/.svn ]; then
2008-11-10 13:31:49 +00:00
echo -e "Updating repository: "$BLUE"trunk"
2008-09-18 21:50:22 +01:00
cd $TRUNK
$SVN update
2008-09-18 21:33:25 +01:00
cd ..
else
echo -e "Checking out repository: "$BLUE"trunk"
$SVN checkout "$REPO/$TRUNK/po" $TRUNK
2008-09-18 21:33:25 +01:00
fi
2008-11-11 22:48:55 +00:00
echo -e $ENDCOLOR
2008-09-18 13:36:37 +01:00
if [ ! -e "$PREFIX-$TRUNK" ]; then
mkdir "$PREFIX-$TRUNK"
fi
fi
for BRANCH in $BRANCHES; do
if [ -e $BRANCH/.svn ]; then
2008-11-10 13:31:49 +00:00
echo -e "Updating repository: $BLUE$BRANCH"
2008-09-18 21:50:22 +01:00
cd $BRANCH
$SVN update
2008-09-18 21:33:25 +01:00
cd ..
else
echo -e "Checking out repository: $BLUE$BRANCH"
$SVN checkout "$REPO/branches/$BRANCH/po" $BRANCH
2008-09-18 21:33:25 +01:00
fi
2008-11-11 22:48:55 +00:00
echo -e $ENDCOLOR
2008-09-18 13:36:37 +01:00
if [ ! -e "$PREFIX-$BRANCH" ]; then
mkdir "$PREFIX-$BRANCH"
fi
done
for BRANCH in $TRUNK $BRANCHES; do
SVNDIR=$BRANCH
DIR="$PREFIX-$BRANCH"
2008-11-11 09:57:24 +00:00
echo -e "Merging: $BLUE$BRANCH"$ENDCOLOR
2008-09-18 13:36:37 +01:00
for dir in `ls $SVNDIR/wesnoth* -d`; do
2009-05-21 14:14:19 +01:00
echo "Processing `basename $dir | sed s/wesnoth-//`.$LCODE.po"
stat=`LC_MESSAGES=C $MSGFMT --statistics -o /dev/null "$dir/$LCODE.po" 2>&1`
2008-10-12 21:20:42 +01:00
u=`echo "$stat" | sed -ne 's/.* \([0-9]\+\) untranslated .*/\1/p'`; u=${u:-0}
2008-09-18 13:36:37 +01:00
f=`echo "$stat" | sed -ne 's/.* \([0-9]\+\) fuzzy translation.*/\1/p'`; f=${f:-0}
file="$DIR/`basename $dir | sed s/wesnoth-//`.$LCODE.po"
2008-09-18 13:36:37 +01:00
if [ -f $dir"/"$LCODE".po" ]; then
if [ -f "$file" ]; then
2009-05-18 11:49:35 +01:00
echo -e $BLUE"Merging:"$ENDCOLOR
$MSGMERGE -U -v "$file" "$dir/`basename $dir`.pot"
2009-05-18 11:49:35 +01:00
rm -f $file~
2008-09-18 13:36:37 +01:00
else
2009-05-18 11:49:35 +01:00
echo -e $RED"Copying:"$ENDCOLOR
cp "$dir/$LCODE.po" "$file"
2008-09-18 13:36:37 +01:00
fi
else
if [ ! -f $file ]; then
2008-11-11 09:57:24 +00:00
echo -e $RED"No po file in repository. Running msginit."$ENDCOLOR
2008-09-18 13:36:37 +01:00
echo "$dir"
$MSGINIT -i "$dir/`basename $dir`.pot" -o $file
else
2008-11-11 09:57:24 +00:00
echo -e $RED"No po file in repository. Found file in workspace."$ENDCOLOR
2008-09-18 13:36:37 +01:00
fi
fi
echo ""
done
done
2008-11-11 09:57:24 +00:00
echo -e $GREEN"Finished."$ENDCOLOR