From 233a9340e08b326803c1038f61cb528b2a9e86c0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 3 Jan 2018 15:01:15 -0500 Subject: Fix internationalization in light of libmakepkg. --- lib/common.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 -- cgit v1.2.3-54-g00ecf