From 4b9f4323abfaa0f4030cc29aed97e0716f9c5852 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 11 Sep 2013 10:18:04 -0400 Subject: 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. --- common.mk | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'common.mk') 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 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) -- cgit v1.2.3-54-g00ecf