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

epm-sh-functions: enable gettext translation

parent 7bfd8de9
...@@ -93,7 +93,7 @@ restore_color() ...@@ -93,7 +93,7 @@ restore_color()
echover() echover()
{ {
[ -z "$verbose" ] && return [ -z "$verbose" ] && return
echo "$*" >&2 echog "$*" >&2
} }
# echo string without EOL # echo string without EOL
...@@ -323,19 +323,27 @@ sudoepm() ...@@ -323,19 +323,27 @@ sudoepm()
sudorun $CMDSHELL $bashopt $PROGDIR/$PROGNAME --inscript "$@" 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 # Print error message and stop the program
fatal() fatal()
{ {
local PROMOMESSAGE="$EPMPROMOMESSAGE" local PROMOMESSAGE="$EPMPROMOMESSAGE"
[ -n "$PROMOMESSAGE" ] || PROMOMESSAGE=" (you can discuss the epm $EPMVERSION problem in Telegram: https://t.me/useepm)" [ -n "$PROMOMESSAGE" ] || PROMOMESSAGE=" (you can discuss the epm $EPMVERSION problem in Telegram: https://t.me/useepm)"
if [ -z "$TEXTDOMAIN" ] ; then
set_color $RED >&2 set_color $RED >&2
echo -n "ERROR: " >&2 echog -n "ERROR: " >&2
restore_color >&2 restore_color >&2
echo "$* $PROMOMESSAGE" >&2 echog "$* $PROMOMESSAGE" >&2
# else
# echog "Error in $0: $@" >&2
fi
# [ "$TERM" = "screen" ] && echo "(screen detected: waiting ten seconds to exit ...)" >&2 && sleep 10 # [ "$TERM" = "screen" ] && echo "(screen detected: waiting ten seconds to exit ...)" >&2 && sleep 10
exit 1 exit 1
} }
...@@ -344,28 +352,21 @@ fatal() ...@@ -344,28 +352,21 @@ fatal()
debug() debug()
{ {
[ -n "$debug" ] || return [ -n "$debug" ] || return
if [ -z "$TEXTDOMAIN" ] ; then
set_color $YELLOW >&2 set_color $YELLOW >&2
echo -n "WARNING: " >&2 echog -n "WARNING: " >&2
restore_color >&2 restore_color >&2
echo "$*" >&2 echog "$*" >&2
# else
# echog "Error in $0: $@" >&2
fi
} }
# Print warning message # Print warning message
warning() warning()
{ {
if [ -z "$TEXTDOMAIN" ] ; then set_color $YELLOW >&2
set_color $YELLOW >&2 echog -n "WARNING: " >&2
echo -n "WARNING: " >&2 restore_color >&2
restore_color >&2 echog "$*" >&2
echo "$*" >&2
# else
# echog "Error in $0: $@" >&2
fi
} }
info() info()
...@@ -375,9 +376,9 @@ info() ...@@ -375,9 +376,9 @@ info()
# print message to stderr if stderr forwarded to (a file) # print message to stderr if stderr forwarded to (a file)
if isatty2 ; then if isatty2 ; then
isatty || return 0 isatty || return 0
echo "$*" echog "$*"
else else
echo "$*" >&2 echog "$*" >&2
fi fi
} }
...@@ -1058,3 +1059,20 @@ check_core_commands() ...@@ -1058,3 +1059,20 @@ check_core_commands()
is_command sed || fatal "Can't find sed command (sed package is missed?)" 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