#!/bin/bash # Update translations from subversion repository and merge them # Copyright (C) 2007-2008 Andrius Štikonas # # 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 . source "`dirname $0`/variables" if [ ! $SVN ]; then echo -e $RED"This program needs the svn utility."$ENDCOLOR exit 1 fi if [ ! $MSGFMT ]; then echo -e $RED"This program needs the msgfmt utility."$ENDCOLOR exit 1 fi if [ ! $MSGMERGE ]; then echo -e $RED"This program needs the msgmerge utility."$ENDCOLOR exit 1 fi if [ ! $MSGINIT ]; then echo -e $RED"This program needs the msginit utility."$ENDCOLOR exit 1 fi echo -e "Language: $RED$LCODE"$ENDCOLOR echo "" if [ ! -z $TRUNK ]; then if [ -e $TRUNK/.svn ]; then echo -e "Updating repository: "$BLUE"trunk" cd $TRUNK $SVN update cd .. else echo -e "Checking out repository: "$BLUE"trunk" $SVN checkout "$REPO/$TRUNK/po" $TRUNK fi echo -e $ENDCOLOR if [ ! -e "$PREFIX-$TRUNK" ]; then mkdir "$PREFIX-$TRUNK" fi fi for BRANCH in $BRANCHES; do if [ -e $BRANCH/.svn ]; then echo -e "Updating repository: $BLUE$BRANCH" cd $BRANCH $SVN update cd .. else echo -e "Checking out repository: $BLUE$BRANCH" $SVN checkout "$REPO/branches/$BRANCH/po" $BRANCH fi echo -e $ENDCOLOR if [ ! -e "$PREFIX-$BRANCH" ]; then mkdir "$PREFIX-$BRANCH" fi done for BRANCH in $TRUNK $BRANCHES; do SVNDIR=$BRANCH DIR="$PREFIX-$BRANCH" echo -e "Merging: $BLUE$BRANCH"$ENDCOLOR for dir in `ls $SVNDIR/wesnoth* -d`; do echo "Processing `basename $dir | sed s/wesnoth-//`.$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 | sed s/wesnoth-//`.$LCODE.po" if [ -f $dir"/"$LCODE".po" ]; then if [ -f "$file" ]; then echo -e $BLUE"Merging:"$ENDCOLOR $MSGMERGE -U -v "$file" "$dir/`basename $dir`.pot" rm -f $file~ else echo -e $RED"Copying:"$ENDCOLOR cp "$dir/$LCODE.po" "$file" fi else if [ ! -f $file ]; then echo -e $RED"No po file in repository. Running msginit."$ENDCOLOR echo "$dir" $MSGINIT -i "$dir/`basename $dir`.pot" -o $file else echo -e $RED"No po file in repository. Found file in workspace."$ENDCOLOR fi fi echo "" done done echo -e $GREEN"Finished."$ENDCOLOR