index : devtools32 | |
Archlinux32 fork of devtools | gitolite user |
summaryrefslogtreecommitdiff |
author | Luke Shumaker <lukeshu@parabola.nu> | 2013-05-02 15:12:42 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2017-05-12 19:42:31 -0400 |
commit | 68cba262451d0d2f2bbfcb868b00fb80588cead7 (patch) | |
tree | 07cd879aa6c6594b2296f7f07b9bec62a4bca70f | |
parent | f4af27b1c166b27db126f01bc2243f5ef76314a8 (diff) |
-rw-r--r-- | lib/common.sh | 32 |
diff --git a/lib/common.sh b/lib/common.sh index 0fb93d9..c3c3454 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -6,8 +6,18 @@ [[ -z ${_INCLUDE_COMMON_SH:-} ]] || return 0 _INCLUDE_COMMON_SH=true -# Avoid any encoding problems -export LANG=C +[[ -n ${TEXTDOMAIN:-} ]] || export TEXTDOMAIN='libretools' +[[ -n ${TEXTDOMAINDIR:-} ]] || export TEXTDOMAINDIR='/usr/share/locale' + +if type gettext &>/dev/null; then + _() { gettext "$@"; } +else + _() { echo "$@"; } +fi + +_l() { + TEXTDOMAIN='librelib' TEXTDOMAINDIR='/usr/share/locale' "$@" +} shopt -s extglob @@ -34,44 +44,44 @@ fi readonly ALL_OFF BOLD BLUE GREEN RED YELLOW plain() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg2() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } warning() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } error() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } stat_busy() { - local mesg=$1; shift + local mesg; mesg="$(_ "$1")"; shift # shellcheck disable=2059 printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2 } stat_done() { # shellcheck disable=2059 - printf "${BOLD}done${ALL_OFF}\n" >&2 + printf "${BOLD}$(_l _ "done")${ALL_OFF}\n" >&2 } _setup_workdir=false @@ -90,7 +100,7 @@ cleanup() { } abort() { - error 'Aborting...' + _l error 'Aborting...' cleanup 255 } @@ -263,7 +273,7 @@ find_cached_package() { return 0 ;; *) - error 'Multiple packages found:' + _l error 'Multiple packages found:' printf '\t%s\n' "${results[@]}" >&2 return 1 esac |