summaryrefslogtreecommitdiff
path: root/common.mk
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-09-11 10:18:04 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-09-11 15:43:36 -0400
commit4b9f4323abfaa0f4030cc29aed97e0716f9c5852 (patch)
tree1dca8650a1a5857f180aaa7704b7b7ee3ba77d32 /common.mk
parent5bbf15572626010ce6e2bc783d0a980fc24662b2 (diff)
libremessages: add a few more message routines, and make them gettext-aware.
- Don't set LANG=C in common.sh - Move TEXTDOMAIN stuff into common.sh; so devtools stuff will use it. - Add _(): Basically an alias for `gettext`, but falls back if gettext is not available. - Add panic(): First showed up in `distcc-tool`, does what it sounds like. - Add prose(), bullet(), and flag(): they do word wrapping and such to make it easy to internationalize `--help` text. - Teach common.mk how to make .pot files based on these routines.
Diffstat (limited to 'common.mk')
-rw-r--r--common.mk24
1 files changed, 24 insertions, 0 deletions
diff --git a/common.mk b/common.mk
index 6c29c03..89ab001 100644
--- a/common.mk
+++ b/common.mk
@@ -17,6 +17,27 @@ indent = emacs --batch $1 \
--eval '(indent-region (point-min) (point-max) nil)' \
-f save-buffer &>/dev/null
+# Usage <INPUT $(pofmt) >OUTPUT
+# Normalize a .po(t) file
+pofmt = msguniq -Fi
+
+pot-remove-wrap = tr '\n' '\r' | sed 's/"\r\s*"//g' | tr '\r' '\n'
+html-whitespace-collapse = sed -r -e 's/(\\n|\\t|\t)/ /g' -e 's/ +/ /g'
+define xgettext-prose =
+ xgettext --omit-header --from-code=UTF-8 -L shell \
+ -k \
+ --keyword={prose,bullet,flag:2} \
+ -o - $^ | $(pot-remove-wrap) | $(html-whitespace-collapse) | sed '/^#, sh-format/d'
+endef
+define xgettext-main =
+ xgettext --omit-header --from-code=UTF-8 -L shell \
+ -k \
+ --keyword={_,print} \
+ --keyword={msg,msg2,warning,error,stat_busy} \
+ --keyword={lock,slock}:3 \
+ -o - $^
+endef
+
# Usage: as a variable
# relative path to `/` from $(bindir)
# used for symlinking libexec files
@@ -69,6 +90,9 @@ build: PHONY $(build_files)
%.html: %.ronn
ronn --html $(RONNFLAGS) < '$<' > '$@'
+%.pot: %
+ { $(xgettext-main); $(xgettext-prose); } | $(pofmt) > '$@'
+
# Install ######################################################################
install: PHONY $(install_files)