#!/bin/sh

# This script is used for translations using .po files.

# This script is meant to be used only once for the transition
# from translating the .xml files to using .po files.

basedir="$(cd "$(dirname $0)"; pwd)"
POFILE=$2
TEMPFILE="/tmp/set_untranslated.$$"

print_usage () {
    echo "Usage: $0 <range> <filename>"
    echo "       where <range> is <number> or <start:end>"
}

if [ "$1" = "--help" ] ; then
    print_usage
    exit 0
fi
if [ $# -ne 2 ] || [ ! -f $POFILE ] ; then
    print_usage
    exit 1
fi


gawk -f $basedir/mark_untranslated.awk -v RANGE="$1" $POFILE >$TEMPFILE
if [ $? -eq 0 ] ; then
    cp $POFILE $POFILE.sv
    cp $TEMPFILE $POFILE

    echo ""
    echo "NOTE"
    echo "The original file has been replaced!"
    echo "A copy of the original file was saved as '$POFILE.sv'."
fi

rm $TEMPFILE
exit 0
