144 lines
3.7 KiB
Bash
Executable File
144 lines
3.7 KiB
Bash
Executable File
#!/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
|
|
echo -e "\E[31mThis program needs the svn utility."; tput sgr0
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! $MSGFMT ]; then
|
|
echo -e "\E[31mThis program needs the msgfmt utility."; tput sgr0
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! $MSGMERGE ]; then
|
|
echo -e "\E[31mThis program needs the msgmerge utility."; tput sgr0
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! $MSGINIT ]; then
|
|
echo -e "\E[31mThis program needs the msginit utility."; tput sgr0
|
|
exit 1
|
|
fi
|
|
|
|
if [ $GIT -eq 1 ] && [ ! $GITSVN ]; then
|
|
echo -e "\E[31mgit-svn is unavailable. svn will be used."; tput sgr0
|
|
GIT=0
|
|
fi
|
|
|
|
if [ $GIT -eq 1 ] && [ $GITSVN ]; then
|
|
SVN="$GITSVN clone"
|
|
fi
|
|
|
|
echo -e "Language: \E[31m$LCODE"; tput sgr0
|
|
echo ""
|
|
|
|
if [ ! -z $TRUNK ]; then
|
|
if [ -e $TRUNK/.git ] || [ -e $TRUNK/.svn ]; then
|
|
echo -e "Updating repository: \E[34mtrunk"
|
|
cd $TRUNK
|
|
if [ $GIT -eq 1 ]; then
|
|
$GITSVN fetch
|
|
$GITSVN rebase
|
|
else
|
|
$SVN update
|
|
fi
|
|
cd ..
|
|
else
|
|
echo -e "Downloading repository: \E[34mtrunk"
|
|
if [ $GIT -eq 1 ]; then
|
|
SVN="$GITSVN clone"
|
|
else
|
|
SVN="$SVN checkout"
|
|
fi
|
|
$SVN "$REPO/$TRUNK/po" $TRUNK
|
|
fi
|
|
tput sgr0
|
|
if [ ! -e "$PREFIX-$TRUNK" ]; then
|
|
mkdir "$PREFIX-$TRUNK"
|
|
fi
|
|
fi
|
|
|
|
for BRANCH in $BRANCHES; do
|
|
if [ -e $BRANCH/.git ] || [ -e $BRANCH/.svn ]; then
|
|
echo -e "Updating repository: \E[34m$BRANCH"
|
|
cd $BRANCH
|
|
if [ $GIT -eq 1 ]; then
|
|
$GITSVN fetch
|
|
$GITSVN rebase
|
|
else
|
|
$SVN update
|
|
fi
|
|
cd ..
|
|
else
|
|
echo -e "Downloading repository: \E[34m$BRANCH"
|
|
if [ $GIT -eq 1 ]; then
|
|
SVN="$GITSVN clone"
|
|
else
|
|
SVN="$SVN checkout"
|
|
fi
|
|
$SVN "$REPO/branches/$BRANCH/po" $BRANCH
|
|
fi
|
|
tput sgr0
|
|
if [ ! -e "$PREFIX-$BRANCH" ]; then
|
|
mkdir "$PREFIX-$BRANCH"
|
|
fi
|
|
done
|
|
|
|
for BRANCH in $TRUNK $BRANCHES; do
|
|
SVNDIR=$BRANCH
|
|
DIR="$PREFIX-$BRANCH"
|
|
echo -e "Merging: \E[34m$BRANCH"; tput sgr0
|
|
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`
|
|
u=`echo "$stat" | sed -ne 's/.* \([0-9]\+\) untranslated .*/\1/p'`; u=${u:-0}
|
|
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
|
|
echo -e "\E[32mFile is translated."; tput sgr0
|
|
if [ -f $DIR"/"`basename $dir`"."$LCODE".po" ]; then
|
|
echo -e "\E[32mRemoving from $DIR."; tput sgr0
|
|
rm -f $file
|
|
fi
|
|
else
|
|
if [ -f "$DIR/"`basename $dir`".$LCODE.po" ]; then
|
|
echo -e "\E[34mMerging:"; tput sgr0
|
|
$MSGMERGE -U -v $file $dir"/"`basename $dir`".pot"
|
|
rm -f $file~
|
|
else
|
|
echo -e "\E[31mCopying:"; tput sgr0
|
|
cp $dir"/"$LCODE".po" $file
|
|
fi
|
|
fi
|
|
else
|
|
if [ ! -f $file ]; then
|
|
echo -e "\E[31mNo po file in repository. Running msginit."; tput sgr0
|
|
echo "$dir"
|
|
$MSGINIT -i "$dir/`basename $dir`.pot" -o $file
|
|
else
|
|
echo -e "\E[31mNo po file in repository. Found file in workspace."; tput sgr0
|
|
fi
|
|
fi
|
|
echo ""
|
|
done
|
|
done
|
|
echo -ne "\E[32mFinished."; tput sgr0; echo " "
|