From 8443cad920a59918069dbee3891b4b9595c528a3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 11 Sep 2013 10:19:02 -0400 Subject: librelib: Internationalize (actually use the internationalization stuff) --- src/lib/librelib | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/lib/librelib') diff --git a/src/lib/librelib b/src/lib/librelib index dc4969f..c5578a2 100755 --- a/src/lib/librelib +++ b/src/lib/librelib @@ -16,9 +16,18 @@ default_libdir=/usr/lib/libretools +if ! type gettext &>/dev/null; then + gettext() { echo "$@"; } +fi + print() { - fmt=$1; shift - printf -- "$fmt\n" "$@" + mesg=$1 + shift + printf -- "$(gettext "$mesg")\n" "$@" +} + +prose() { + print "$@" | fmt -su } cmd=${0##*/} @@ -27,17 +36,16 @@ usage() { print 'Usage: . $(%s LIBRARY)' "$cmd" print "Finds a shell library file" echo - print "While some libraries can be sourced just by their name because" - print "they are installed in PATH (like libremessages), some are not" - print "installed there (like conf.sh), so a path must be given." - print "Hardcoding that path is the way of the dark side." + prose "While some libraries can be sourced just by their name because + they are installed in PATH (like libremessages), some are not + installed there (like conf.sh), so a path must be given. + Hardcoding that path is the way of the dark side." echo - print "By default, it looks for the files in '%s'," "$default_libdir" - print "but this can be changed with the environmental variable" - print "LIBRETOOLS_LIBDIR." + prose 'By default, it looks for the files in `%s`, but this can be + changed with the environmental variable LIBRETOOLS_LIBDIR.' "$default_libdir" echo print "Example usage:" - print ' . $(librelib conf.sh)' + printf ' . $(%s conf.sh)\n' "$cmd" } main() { @@ -64,7 +72,7 @@ main() { return 0; fi done - printf 'librelib: could not find library `%s`\n' "$lib" >> /dev/stderr + print '%s: could not find library: %s' "$cmd" "$lib" >> /dev/stderr return 1 } -- cgit v1.2.3-54-g00ecf