#!/bin/bash
#
# Build for PCLinuxOS 2010
# By Leiche (kellerleicheorig at aol.com)
# Licence GPL
# Generate pot, and *-language.po files, to translate bash scripts
# Aug Sun 08 2010
# 
Encoding=UTF-8
#
# check Desktop terminals
#
if [ -f /usr/bin/terminal ];then
TERM=terminal
elif [ -f /usr/bin/lxterminal ];then
TERM=lxterminal
elif [ -f /usr/bin/sakura ];then
TERM=sakura
elif [ -f /usr/bin/konsole ];then
TERM=konsole
elif [ -f /usr/bin/qtermnal ];then
TERM=qterminal
else
TERM=xterm
fi
#
usage ()
{
echo "No File"
#if [ -f ~/.config/locale.conf ]; then
#	zenity --question --title "Bash-Script-Translator-Generator" --text $"Do you want to set your favorite language?"
#else	
exit 1 #exit script
#fi
}
#
if [ $# -eq 0 ];
then
usage
fi
#
SCRIPT="$1"
#
SAVE=$(zenity --file-selection --title "Bash-Script-Translator-Generator" --save --filename=$SCRIPT)
if [ "$SAVE" = "" ];then
exit
else
LOCALE=$(cat /etc/sysconfig/i18n |grep LC_CTYPE |tail -1 |cut -c 10-14)
bash --dump-po-strings "$SCRIPT" | xgettext -L PO -o $SAVE.pot -
$TERM -e "msginit -l $LOCALE -i $SAVE.pot -o $SAVE-$LOCALE.po"
fi
exit
