Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2018-01-03 15:01:15 -0500
committerLuke Shumaker <lukeshu@parabola.nu>2018-01-03 15:01:15 -0500
commit233a9340e08b326803c1038f61cb528b2a9e86c0 (patch)
tree53f4a8959208b6a2dca2322951e82f84d4d6f6bc
parentbbd78fcfb86301ef761057a7c2b10fcb6d8402a1 (diff)
Fix internationalization in light of libmakepkg.
-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