summaryrefslogtreecommitdiff
path: root/src/lib/librelib
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-05 17:09:11 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-05 18:50:09 -0500
commit56384e572d419a48439a90b9481a715a13a109c8 (patch)
treefc132badb5cde0ff2e5713d0cdd2725980306120 /src/lib/librelib
parentf5663f08d44091ca16c7f53c492c2594202ba7e5 (diff)
src/lib/: set TEXTDOMAIN differently for internal messages
This allows us to fix the long-standing bug that libremessages forces TEXTDOMAIN=libretools
Diffstat (limited to 'src/lib/librelib')
-rwxr-xr-xsrc/lib/librelib29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/lib/librelib b/src/lib/librelib
index a58f5d3..3b05e37 100755
--- a/src/lib/librelib
+++ b/src/lib/librelib
@@ -16,18 +16,31 @@
default_libdir=/usr/lib/libretools
-if ! type gettext &>/dev/null; then
- gettext() { echo "$@"; }
+if type gettext &>/dev/null; then
+ _() { gettext "$@"; }
+else
+ _() { echo "$@"; }
fi
+_l() {
+ TEXTDOMAIN='librelib' TEXTDOMAINDIR='/usr/share/locale' "$@"
+}
+
print() {
- mesg=$1
+ local mesg="$(_ "$1")"
shift
- printf -- "$(gettext "$mesg")\n" "$@"
+ printf -- "$mesg\n" "$@"
+}
+
+_html_whitespace_collapse() {
+ [[ $# == 0 ]] || panic
+ tr '\n' ' ' | sed -r -e 's/\t/ /g' -e 's/ +/ /g'
}
prose() {
- print "$@" | fmt -su
+ [[ $# -ge 1 ]] || panic
+ local mesg="$(_ "$(_html_whitespace_collapse <<<"$1")")"; shift
+ printf -- "$mesg" "$@" | fmt -u
}
cmd=${0##*/}
@@ -54,11 +67,11 @@ usage() {
main() {
if [[ $# != 1 ]]; then
- usage >&2
+ _l usage >&2
return 2
fi
if [[ $1 == '-h' ]]; then
- usage
+ _l usage
return 0;
fi
@@ -76,7 +89,7 @@ main() {
return 0;
fi
done
- print '%s: could not find library: %s' "$cmd" "$lib" >> /dev/stderr
+ _l print '%s: could not find library: %s' "$cmd" "$lib" >> /dev/stderr
return 1
}