summaryrefslogtreecommitdiff
path: root/src/lib/librelib
diff options
context:
space:
mode:
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
}