File gnome-patch-translation-prepare of Package gnome-patch-translation

#! /bin/bash

if test "$1" = "--help" ; then
    echo "Patch translation update tool works in top directory of unpacked source code."
    echo "$0 is an utility that is called before applying of patches."
    echo "Usage: $0 [translation_directory] [translation_domain] [command to create pot file]"
fi

set -o errexit
shopt -s nullglob

TOP_DIR=$PWD
DIR=${1:-po}
DOMAIN=$2
if test -d "$1" ; then
	EXT=."$1"
else
	EXT=
fi
cd "$DIR"


# This action takes some time. But run it every time to confirm, that update is still needed.
if test -z "$3" ; then
    if test -z "$DOMAIN" ; then
	intltool-update --pot
    else
	intltool-update --gettext-package=$DOMAIN --pot
    fi
else
    eval $3
fi

POT_NOT_UNIQUE=false
MISSING=true
for POT in *.pot ; do
    if $POT_NOT_UNIQUE ; then
	echo "ERROR: Directory $DIR contains more than one .pot file."
	exit 1
    fi
    POT_NOT_UNIQUE=true
    MISSING=false

    mkdir -p "../gnome-patch-translation$EXT/old"
    mv "$POT" "../gnome-patch-translation$EXT/old"

done
if $MISSING ; then
    echo "ERROR: Directory $DIR does not contains any .pot file."
    exit 1
fi
openSUSE Build Service is sponsored by