summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/common.sh b/lib/common.sh
index d3f4f7c..56929a7 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -27,6 +27,10 @@ _l() {
TEXTDOMAIN='librelib' TEXTDOMAINDIR='/usr/share/locale' "$@"
}
+_p() {
+ TEXTDOMAIN='pacman-scripts' TEXTDOMAINDIR='/usr/share/locale' "$@"
+}
+
shopt -s extglob
# check if messages are to be printed using color
@@ -37,6 +41,27 @@ else
declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
fi
+# makepkg message functions expect gettext to already be called; like
+# `msg "$(gettext 'Hello World')"`. Where libretools expects the
+# message functions to call gettext. So, we'll do some magic to wrap
+# the makepkg versions.
+eval "$(
+ fns=(
+ plain
+ msg
+ msg2
+ warning
+ error
+ )
+
+ # declare _makepkg_${fn} as a copy of ${fn}
+ declare -f "${fns[@]}" | sed 's/^[a-z]/_makepkg_&/'
+
+ # re-declare ${fn} as a wrapper around _makepkg_${fn}
+ printf '%s() { local mesg; mesg="$(_ "$1")"; _p _makepkg_"${FUNCNAME[0]}" "$mesg" "${@:2}"; }\n' \
+ "${fns[@]}"
+)"
+
stat_busy() {
local mesg; mesg="$(_ "$1")"; shift
# shellcheck disable=2059