[pacman-dev] [RFC v3 13/13] bacman: make gettext useful

Gordian Edenhofer gordian.edenhofer at gmail.com
Fri Sep 30 11:48:01 UTC 2016


Export TEXTDOMAIN and TEXTDOMAINDIR in order for the strings to be
translatable with gettext.
---
 contrib/bacman.sh.in | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 39fbe99..cc243c9 100644
--- a/contrib/bacman.sh.in
+++ b/contrib/bacman.sh.in
@@ -32,6 +32,17 @@ QUIET=0
 # Required for fakeroot because options are shifted off the array.
 ARGS=("$@")
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+	gettext() {
+		printf "%s\n" "$@"
+	}
+fi
+
 m4_include(../scripts/library/output_format.sh)
 m4_include(../scripts/library/parseopts.sh)
 
@@ -54,13 +65,18 @@ usage() {
 	printf -- "$(gettext "Usage: %s [options] <package(s)>")\n" "$0"
 	echo
 	printf -- "$(gettext "Options:")\n"
-	printf -- "$(gettext "  -h, --help       Show this help message and exit")\n"
-	printf -- "$(gettext "  -q, --quiet      Silence most of the status reporting")\n"
-	printf -- "$(gettext "  -m, --nocolor    Disable colorized output messages")\n"
-	printf -- "$(gettext "  -o, --out <dir>  Write output to specified directory (instead of \$PKGDEST)")\n"
-	printf -- "$(gettext "  --pacnew         Package .pacnew files")\n"
+	printf -- "  -h, --help       "
+	printf -- "$(gettext "Show this help message and exit")\n"
+	printf -- "  -q, --quiet      "
+	printf -- "$(gettext "Silence most of the status reporting")\n"
+	printf -- "  -m, --nocolor    "
+	printf -- "$(gettext "Disable colorized output messages")\n"
+	printf -- "  -o, --out <dir>  "
+	printf -- "$(gettext "Write output to specified directory (instead of %s)")\n" "\$PKGDEST"
+	printf -- "  --pacnew         "
+	printf -- "$(gettext "Package .pacnew files")\n"
 	echo
-	printf -- "$(gettext "Examples:")" 
+	printf -- "$(gettext "Examples:")"
 	printf -- "    %s linux-headers\n" "$myname"
 	printf -- "    %s -o ~/packages libarchive\n" "$myname"
 	printf -- "    %s --nocolor --pacnew gzip make binutils\n" "$myname"
-- 
2.10.0


More information about the pacman-dev mailing list