--- /dev/null
+#!/usr/bin/make -f
+#-
+# Application demonstration for GNU gettext in shell scripts.
+# Copyright © 2015 mirabilos <t.glaser@tarent.de>
+# Published under any OSI-approved Open Source licence.
+
+P=itest
+V=1.0
+B=t.glaser@tarent.de
+D=itest
+
+all:
+
+clean:
+ rm -rf mo po/*.pot po/*~
+
+all: update-translations install-translations
+
+update-translations:
+ -rm -f po/$D.pot
+ find * -name \*.sh | xargs perl -pi -e 's!^(TEXTDOMAIN=).*$$!$$1$D!'
+ find * -name \*.sh | xgettext -f - -d $D -o po/$D.pot \
+ -L Shell --from-code=UTF-8 --check=ellipsis-unicode \
+ --check=space-ellipsis --check=quote-unicode \
+ --sentence-end=single-space -k_ -F --foreign-user \
+ --package-name=$P --package-version=$V \
+ --msgid-bugs-address=$B
+ set -e; for x in po/*.po; do \
+ msgmerge -U "$$x" po/$D.pot; \
+ done
+
+install-translations:
+ rm -rf mo
+ set -e; for x in po/*.po; do \
+ l=$${x##*/}; l=$${l%.po}; \
+ mkdir -p "mo/$$l/LC_MESSAGES"; \
+ msgfmt -o "mo/$$l/LC_MESSAGES/$D.mo" "$$x"; \
+ done
+
+.PHONY: all clean update-translations install-translations
--- /dev/null
+#!/bin/sh
+#-
+# Application demonstration for GNU gettext in shell scripts.
+# Copyright © 2015 mirabilos <t.glaser@tarent.de>
+# Published under any OSI-approved Open Source licence.
+#-
+# Call with, e.g: $ LC_ALL=de_DE.UTF-8 sh itest.sh x y z
+
+. gettext.sh
+TEXTDOMAIN=itest
+TEXTDOMAINDIR=$(dirname "$0")/mo
+export TEXTDOMAIN TEXTDOMAINDIR
+
+test -z "$KSH_VERSION" || echo='print -r --'
+_() {
+ $echo "$(eval_gettext "$1")"
+}
+
+echo Internationalised program test: language:
+locale
+echo
+
+_ "Hello, World!"
+_ "Five O’Clock is tea time!"
+
+nargs=$#
+$echo "$(eval_ngettext "This script was called with one argument." \
+ "This script was called with \${nargs} arguments." $nargs)"
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: itest 1.0\n"
+"Report-Msgid-Bugs-To: t.glaser@tarent.de\n"
+"POT-Creation-Date: 2015-08-28 14:20+0200\n"
+"PO-Revision-Date: 2015-08-28 13:39+0200\n"
+"Last-Translator: mirabilos <t.glaser@tarent.de>\n"
+"Language-Team: German\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: itest.sh:23
+msgid "Hello, World!"
+msgstr "Hallo, Welt!"
+
+#: itest.sh:24
+msgid "Five O’Clock is tea time!"
+msgstr "Um fünf Uhr ist Teezeit!"
+
+#: itest.sh:27
+#, sh-format
+msgid "This script was called with one argument."
+msgid_plural "This script was called with ${nargs} arguments."
+msgstr[0] "Dieses Skript wurde mit einem Argument aufgerufen."
+msgstr[1] "Dieses Skript wurde mit ${nargs} Argumenten aufgerufen."
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: itest 1.0\n"
+"Report-Msgid-Bugs-To: t.glaser@tarent.de\n"
+"POT-Creation-Date: 2015-08-28 14:20+0200\n"
+"PO-Revision-Date: 2015-08-28 13:40+0200\n"
+"Last-Translator: mirabilos <t.glaser@tarent.de>\n"
+"Language-Team: Spanish\n"
+"Language: es\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: itest.sh:23
+msgid "Hello, World!"
+msgstr "¡Hola el mundo!"
+
+#: itest.sh:24
+msgid "Five O’Clock is tea time!"
+msgstr "Á las cincos hace té."
+
+#: itest.sh:27
+#, sh-format
+msgid "This script was called with one argument."
+msgid_plural "This script was called with ${nargs} arguments."
+msgstr[0] ""
+msgstr[1] ""
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: itest 1.0\n"
+"Report-Msgid-Bugs-To: t.glaser@tarent.de\n"
+"POT-Creation-Date: 2015-08-28 14:20+0200\n"
+"PO-Revision-Date: 2015-08-28 14:10+0200\n"
+"Last-Translator: mirabilos <t.glaser@tarent.de>\n"
+"Language-Team: French\n"
+"Language: fr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: itest.sh:23
+msgid "Hello, World!"
+msgstr ""
+
+#: itest.sh:24
+msgid "Five O’Clock is tea time!"
+msgstr ""
+
+#: itest.sh:27
+#, sh-format
+msgid "This script was called with one argument."
+msgid_plural "This script was called with ${nargs} arguments."
+msgstr[0] ""
+msgstr[1] ""