#!/bin/bash
#
#  Sparky-Wine is a simply tool which let you install ".exe" application using Wine.
#  Created by Paweł "pavroo" Pijanowski 2014/03/04
#  Copyright 2014-2024 under the GNU GPL2 License
#  Last update 2024/07/30

# get default's locale file
DEFLOCDIR="/usr/share/sparky/sparky-wine"
if [ "`cat /etc/default/locale | grep LANG= | grep ar`" != "" ]; then
. $DEFLOCDIR/ar
elif [ "`cat /etc/default/locale | grep LANG= | grep de`" != "" ]; then
. $DEFLOCDIR/de
elif [ "`cat /etc/default/locale | grep LANG= | grep el`" != "" ]; then
. $DEFLOCDIR/el
elif [ "`cat /etc/default/locale | grep LANG= | grep es`" != "" ]; then
	if [ "`cat /etc/default/locale | grep LANG= | grep es_AR`" != "" ]; then
. $DEFLOCDIR/es_AR
	else
. $DEFLOCDIR/es_ES
	fi
elif [ "`cat /etc/default/locale | grep LANG= | grep fr`" != "" ]; then
. $DEFLOCDIR/fr
elif [ "`cat /etc/default/locale | grep LANG= | grep fi`" != "" ]; then
. $DEFLOCDIR/fi
elif [ "`cat /etc/default/locale | grep LANG= | grep hu`" != "" ]; then
. $DEFLOCDIR/hu
elif [ "`cat /etc/default/locale | grep LANG= | grep id_ID`" != "" ]; then
. $DEFLOCDIR/id_ID
elif [ "`cat /etc/default/locale | grep LANG= | grep it`" != "" ]; then
. $DEFLOCDIR/it
elif [ "`cat /etc/default/locale | grep LANG= | grep ja`" != "" ]; then
. $DEFLOCDIR/ja
elif [ "`cat /etc/default/locale | grep LANG= | grep pl`" != "" ]; then
. $DEFLOCDIR/pl
elif [ "`cat /etc/default/locale | grep LANG= | grep pt_BR`" != "" ]; then
. $DEFLOCDIR/pt_BR
elif [ "`cat /etc/default/locale | grep LANG= | grep pt_PT`" != "" ]; then
. $DEFLOCDIR/pt_PT
elif [ "`cat /etc/default/locale | grep LANG= | grep ru`" != "" ]; then
. $DEFLOCDIR/ru
elif [ "`cat /etc/default/locale | grep LANG= | grep uk`" != "" ]; then
. $DEFLOCDIR/uk
elif [ "`cat /etc/default/locale | grep LANG= | grep zh_CN`" != "" ]; then
. $DEFLOCDIR/zh_CN
else
. $DEFLOCDIR/en
fi

DIALOG700="`which yad` --window-icon=wine --width=700 --height=500 --center"
DIALOG="`which yad` --window-icon=wine --width=450 --height=200 --center"
TITLE="--always-print-result --dialog-sep --image=wine --title="
TEXT="--text="
TITLETEXT="$LOCAL1"
FILESELECTION="--file "
FILTER="--file-filter"
OKEXIT=" --button=Ok:0 --button=$LOCAL6:1 "
MSGBOX=" --button=Ok:0 "

EXEFILE=`$DIALOG700 $TITLE"$LOCAL2" $OKEXIT $FILESELECTION $FILTER="EXE file |*.exe"`

if [ "$?" != "0" ]; then
	$DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"$LOCAL3"
	exit 1

elif [ "$EXEFILE" = "" ]; then
	$DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"$LOCAL4"
	exit 1

else

	wine $EXEFILE
	$DIALOG $TITLE"$TITLETEXT" $MSGBOX $TEXT"$LOCAL5"
	exit 0
fi

exit 0
