#!/bin/sh
# Script to add a new language to khangman

# Check parameters
if test $# = 0 || test $# -gt 1 || test $1 = "--help" ; then
  echo "usage: add_language <language_code>"
  exit
fi
echo "Please send your files tarred and zipped to annemarie.mahfouf@free.fr and note anything specific to your language such as special characters. Please add all special characters in a text file. Thanks a lot.

The script will carry on, please just do not commit the files. Please NEVER commit in a BRANCH."

# Check for valid language code
all_langs=$TDEDIR/share/locale/all_languages
if test -e $all_langs ; then
  grep -q "^\[$1\]$" $all_langs
  if test $? != 0 ; then
    echo "add_language: error: \"$1\" is not a valid language code"
    exit
  fi
fi

# Set up variables
code=$1
dir=khangman/data
lang=$dir/$code
en=$dir/en

# Check if directory already exists
if test -e $lang ; then
  echo "add_language: error: \"$1\" already exists"
  exit
fi

# Create the directory and copy files to it
mkdir $lang
cp $dir/en/*.txt $lang
sed -e "s/\/en/\/$code/" $en/Makefile.am > $lang/Makefile.am
touch $dir/Makefile.am

# Tell user what to do
echo "The language $code has been successfully added!"
echo ""
echo "Please edit the following files and translate the english words and english hints:"
ls $lang/*.txt
echo ""
echo "The files now use the kvtml format."
echo "See http://edu.kde.org/khangman/add_language.php for more information."
echo "Thanks a lot for your contribution!"