104 lines
3.0 KiB
Bash
104 lines
3.0 KiB
Bash
|
#!/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
|
||
|
|
||
|
echo -e "Language: \E[31m$LCODE"; tput sgr0
|
||
|
echo ""
|
||
|
|
||
|
if [ ! -z $TRUNK ]; then
|
||
|
echo -e "Updating repository: \E[34mtrunk"
|
||
|
$SVN co "$REPO/$TRUNK/po" $TRUNK
|
||
|
tput sgr0
|
||
|
if [ ! -e "$PREFIX-$TRUNK" ]; then
|
||
|
mkdir "$PREFIX-$TRUNK"
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
for BRANCH in $BRANCHES; do
|
||
|
echo -e "Updating repository: \E[34m$BRANCH"
|
||
|
$SVN co "$REPO/branches/$BRANCH/po" $BRANCH
|
||
|
tput sgr0
|
||
|
done
|
||
|
|
||
|
for BRANCH in $BRANCHES; do
|
||
|
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 " "
|