wesnoth-l10n-tools/update.sh

142 lines
3.7 KiB
Bash
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/>.
source variables
if [ ! $SVN ]; then
2008-11-10 13:31:49 +00:00
echo -e $RED"This program needs the svn utility."; tput sgr0
2008-09-18 13:36:37 +01:00
exit 1
fi
if [ ! $MSGFMT ]; then
2008-11-10 13:31:49 +00:00
echo -e $RED"This program needs the msgfmt utility."; tput sgr0
2008-09-18 13:36:37 +01:00
exit 1
fi
if [ ! $MSGMERGE ]; then
2008-11-10 13:31:49 +00:00
echo -e $RED"This program needs the msgmerge utility."; tput sgr0
2008-09-18 13:36:37 +01:00
exit 1
fi
if [ ! $MSGINIT ]; then
2008-11-10 13:31:49 +00:00
echo -e $RED"This program needs the msginit utility."; tput sgr0
2008-09-18 13:36:37 +01:00
exit 1
fi
2008-09-18 21:50:22 +01:00
if [ $GIT -eq 1 ] && [ ! $GITSVN ]; then
2008-11-10 13:31:49 +00:00
echo -e $RED"git-svn is unavailable. svn will be used."; tput sgr0
2008-09-18 14:06:21 +01:00
GIT=0
fi
2008-09-18 21:50:22 +01:00
if [ $GIT -eq 1 ] && [ $GITSVN ]; then
2008-09-18 14:06:21 +01:00
SVN="$GITSVN clone"
fi
2008-11-10 13:31:49 +00:00
echo -e "Language: $RED$LCODE"; tput sgr0
2008-09-18 13:36:37 +01:00
echo ""
if [ ! -z $TRUNK ]; then
2008-09-18 21:36:42 +01:00
if [ -e $TRUNK/.git ] || [ -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
if [ $GIT -eq 1 ]; then
$GITSVN rebase
2008-09-18 21:33:25 +01:00
else
2008-09-18 21:50:22 +01:00
$SVN update
2008-09-18 21:33:25 +01:00
fi
cd ..
else
2008-11-10 13:31:49 +00:00
echo -e "Downloading repository: "$BLUE"trunk"
2008-09-18 21:50:22 +01:00
if [ $GIT -eq 1 ]; then
2008-09-18 21:33:25 +01:00
SVN="$GITSVN clone"
else
SVN="$SVN checkout"
fi
$SVN "$REPO/$TRUNK/po" $TRUNK
fi
2008-09-18 13:36:37 +01:00
tput sgr0
if [ ! -e "$PREFIX-$TRUNK" ]; then
mkdir "$PREFIX-$TRUNK"
fi
fi
for BRANCH in $BRANCHES; do
2008-09-18 21:36:42 +01:00
if [ -e $BRANCH/.git ] || [ -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
if [ $GIT -eq 1 ]; then
$GITSVN rebase
2008-09-18 21:33:25 +01:00
else
2008-09-18 21:50:22 +01:00
$SVN update
2008-09-18 21:33:25 +01:00
fi
cd ..
else
2008-11-10 13:31:49 +00:00
echo -e "Downloading repository: $BLUE$BRANCH"
2008-09-18 21:50:22 +01:00
if [ $GIT -eq 1 ]; then
2008-09-18 21:33:25 +01:00
SVN="$GITSVN clone"
else
SVN="$SVN checkout"
fi
2008-09-30 14:42:00 +01:00
$SVN "$REPO/branches/$BRANCH/po" $BRANCH
2008-09-18 21:33:25 +01:00
fi
2008-09-18 13:36:37 +01:00
tput sgr0
if [ ! -e "$PREFIX-$BRANCH" ]; then
mkdir "$PREFIX-$BRANCH"
fi
done
for BRANCH in $TRUNK $BRANCHES; do
SVNDIR=$BRANCH
DIR="$PREFIX-$BRANCH"
2008-11-10 13:31:49 +00:00
echo -e "Merging: $BLUE$BRANCH"; tput sgr0
2008-09-18 13:36:37 +01:00
for dir in `ls $SVNDIR/wesnoth* -d`; do
echo "Processing "`basename $dir`"."$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`"."$LCODE".po"
if [ -f $dir"/"$LCODE".po" ]; then
if [ $(($u+$f)) == 0 ]; then
2008-11-10 13:31:49 +00:00
echo -e $GREEN"File is translated."; tput sgr0
2008-09-18 13:36:37 +01:00
if [ -f $DIR"/"`basename $dir`"."$LCODE".po" ]; then
2008-11-10 13:31:49 +00:00
echo -e $GREEN"Removing from $DIR."; tput sgr0
2008-09-18 13:36:37 +01:00
rm -f $file
fi
else
if [ -f "$DIR/"`basename $dir`".$LCODE.po" ]; then
2008-11-10 13:31:49 +00:00
echo -e $BLUE"Merging:"; tput sgr0
2008-09-18 13:36:37 +01:00
$MSGMERGE -U -v $file $dir"/"`basename $dir`".pot"
rm -f $file~
else
2008-11-10 13:31:49 +00:00
echo -e $RED"Copying:"; tput sgr0
2008-09-18 13:36:37 +01:00
cp $dir"/"$LCODE".po" $file
fi
fi
else
if [ ! -f $file ]; then
2008-11-10 13:31:49 +00:00
echo -e $RED"No po file in repository. Running msginit."; tput sgr0
2008-09-18 13:36:37 +01:00
echo "$dir"
$MSGINIT -i "$dir/`basename $dir`.pot" -o $file
else
2008-11-10 13:31:49 +00:00
echo -e $RED"No po file in repository. Found file in workspace."; tput sgr0
2008-09-18 13:36:37 +01:00
fi
fi
echo ""
done
done
2008-11-10 13:31:49 +00:00
echo -ne $GREEN"Finished."; tput sgr0; echo " "