#!/bin/sh

script_path=`echo $0 | awk -F '/' '{for(i=2;i<NF;i++) printf"/"$i}'`

echo  $script_path >> test

LANGUAGE=`cat $script_path/language.ini | ./busybox grep "DefaultLanguage:" | ./busybox grep -v grep | sed 's/DefaultLanguage://g' | sed 's/\r//g' | sed 's/\n//g' | sed "s/$(echo -e '\015')//g"`
if [ $? != 0 ]; then
	echo "cann't found language in config file"
	exit -1
fi

echo LANGUAGE = $LANGUAGE >> test
rm -f /mnt/mtd/Log/SupportLanguage
#echo -e "$LANGUAGE" > /mnt/mtd/Log/SupportLanguage
echo $LANGUAGE > /mnt/mtd/Log/InitialLanguage

if [ $? != 0 ]; then
	./playOrRecord -p 0 audio/configLanguage_fail.pcm
	exit -1
fi


LanuageAudioName=audio/configLanguage$LANGUAGE.pcm

if [ -f $LanuageAudioName ];then
	./playOrRecord -p 0 $LanuageAudioName
else
	./playOrRecord -p 0 audio/LanguageUnknown.pcm
fi

