#!/bin/sh
operation=$1
lang=$2
SIMOPTIONS=

# Check to see if parameters are correct.
if [ "$operation" = ""   -o  "$3" != "" ]
then 
    echo "   'simtranslate' is used to extract English text files from SIM"
    echo "   into a subdirectory so that the text can be translated to another"
    echo "   language and then staged back into SIM for testing."
    echo " "
    echo "   For example:"
    echo "     1)  Export English text from SIM to a subdirectory with the "
    echo "         following command:"
    echo " "
    echo "             simtranslate extract "
    echo " "
    echo "     2)  Copy the English text for translation for 'zh_CN'."
    echo " "
    echo "             simtranslate copy  zh_CN"
    echo " "
    echo "     3)  Manually edit the files in 'zh_CN' to translate the text to Chinese."
    echo " "
    echo "     4)  Stage the Chinese files from 'zh_CN' with the following command:"
    echo " "
    echo "             simtranslate stage zh_CN"
    echo " "
    echo "     5)  Restart SIM to load the changes."
    echo " "
    echo " "
    echo "   Usage:  "
    echo "           To export properties files from SIM to an external directory:"
    echo " "
    echo "                simtranslate extract"
    echo " "
    echo "           To create a language directory:"
    echo " "
    echo "                simtranslate copy  lang"
    echo " "
    echo "           To import the translated properties files into SIM:"
    echo " "
    echo "                simtranslate stage lang"
    echo " "
    echo "           where 'lang' can be 'zh_CN', 'zh_TW' or 'ko'."
    echo " "

    exit 500
fi

antloc="/opt/mx"
if [ -e "/opt/hpwebadmin/webapps/mxhelp/WEB-INF/lib/ant.jar" ]
then
    antloc="/opt/hpwebadmin/webapps/mxhelp/WEB-INF"
fi

if [ x$ANT_HOME = "x" ]
then
    export PATH=$PATH:/opt/mx/lbin:/opt/mx/lib
    /opt/mx/j2re/bin/java -classpath "$antloc/lib/ant-launcher.jar:$antloc/lib/ant.jar:$antloc/lib/ant-nodeps.jar:/opt/mx/lbin/ant-nodeps-1.6.2.jar:/opt/mx/j2re/lib/tools.jar" "-Dant.home=/opt/mx" org.apache.tools.ant.launch.Launcher $operation -f "simtranslate.xml" -Ddir.SIM="/" -Dlang.new.locale=$lang
else
    $ANT_HOME/bin/ant -f simtranslate.xml -Dant.home=$ANT_HOME -Ddir.SIM="/" -Dlang.new.locale=$lang $operation
fi
