i18n/l10n testcase
authormirabilos <t.glaser@tarent.de>
Fri, 28 Aug 2015 12:20:57 +0000 (14:20 +0200)
committermirabilos <t.glaser@tarent.de>
Fri, 28 Aug 2015 12:20:57 +0000 (14:20 +0200)
posix/itest/Makefile [new file with mode: 0755]
posix/itest/itest.sh [new file with mode: 0755]
posix/itest/po/de.po [new file with mode: 0644]
posix/itest/po/es.po [new file with mode: 0644]
posix/itest/po/fr.po [new file with mode: 0644]

diff --git a/posix/itest/Makefile b/posix/itest/Makefile
new file mode 100755 (executable)
index 0000000..9142957
--- /dev/null
@@ -0,0 +1,40 @@
+#!/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
diff --git a/posix/itest/itest.sh b/posix/itest/itest.sh
new file mode 100755 (executable)
index 0000000..3bfb841
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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)"
diff --git a/posix/itest/po/de.po b/posix/itest/po/de.po
new file mode 100644 (file)
index 0000000..3e2f280
--- /dev/null
@@ -0,0 +1,28 @@
+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."
diff --git a/posix/itest/po/es.po b/posix/itest/po/es.po
new file mode 100644 (file)
index 0000000..6f5c7e4
--- /dev/null
@@ -0,0 +1,28 @@
+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] ""
diff --git a/posix/itest/po/fr.po b/posix/itest/po/fr.po
new file mode 100644 (file)
index 0000000..722cfd5
--- /dev/null
@@ -0,0 +1,28 @@
+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] ""