Commit 6de8107e authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-sh-functions: enable gettext translation

parent 7bfd8de9
......@@ -93,7 +93,7 @@ restore_color()
echover()
{
[ -z "$verbose" ] && return
echo "$*" >&2
echog "$*" >&2
}
# echo string without EOL
......@@ -323,19 +323,27 @@ sudoepm()
sudorun $CMDSHELL $bashopt $PROGDIR/$PROGNAME --inscript "$@"
}
echog()
{
if [ "$1" = "-n" ] ; then
shift
eval_gettext "$*"
else
eval_gettext "$*"; echo
fi
}
# Print error message and stop the program
fatal()
{
local PROMOMESSAGE="$EPMPROMOMESSAGE"
[ -n "$PROMOMESSAGE" ] || PROMOMESSAGE=" (you can discuss the epm $EPMVERSION problem in Telegram: https://t.me/useepm)"
if [ -z "$TEXTDOMAIN" ] ; then
set_color $RED >&2
echo -n "ERROR: " >&2
restore_color >&2
echo "$* $PROMOMESSAGE" >&2
# else
# echog "Error in $0: $@" >&2
fi
set_color $RED >&2
echog -n "ERROR: " >&2
restore_color >&2
echog "$* $PROMOMESSAGE" >&2
# [ "$TERM" = "screen" ] && echo "(screen detected: waiting ten seconds to exit ...)" >&2 && sleep 10
exit 1
}
......@@ -344,28 +352,21 @@ fatal()
debug()
{
[ -n "$debug" ] || return
if [ -z "$TEXTDOMAIN" ] ; then
set_color $YELLOW >&2
echo -n "WARNING: " >&2
restore_color >&2
echo "$*" >&2
# else
# echog "Error in $0: $@" >&2
fi
set_color $YELLOW >&2
echog -n "WARNING: " >&2
restore_color >&2
echog "$*" >&2
}
# Print warning message
warning()
{
if [ -z "$TEXTDOMAIN" ] ; then
set_color $YELLOW >&2
echo -n "WARNING: " >&2
restore_color >&2
echo "$*" >&2
# else
# echog "Error in $0: $@" >&2
fi
set_color $YELLOW >&2
echog -n "WARNING: " >&2
restore_color >&2
echog "$*" >&2
}
info()
......@@ -375,9 +376,9 @@ info()
# print message to stderr if stderr forwarded to (a file)
if isatty2 ; then
isatty || return 0
echo "$*"
echog "$*"
else
echo "$*" >&2
echog "$*" >&2
fi
}
......@@ -1058,3 +1059,20 @@ check_core_commands()
is_command sed || fatal "Can't find sed command (sed package is missed?)"
}
export TEXTDOMAIN=eepm
if [ "$EPMMODE" = "git" ] ; then
TEXTDOMAINDIR=$PROGDIR/../po
else
TEXTDOMAINDIR='/usr/share/locale'
fi
export TEXTDOMAINDIR
if [ -d "$TEXTDOMAINDIR" ] && is_command gettext.sh ; then
. gettext.sh
else
eval_gettext()
{
echo -n $@
}
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment