summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/msgexec-5
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2014-05-15 15:18:35 +0900
committerDaiki Ueno <ueno@gnu.org>2014-05-15 15:39:33 +0900
commit70501a1599a3f4052fac1801263d6cc168fb17e0 (patch)
tree11e05024f71c6918a5420d4c2f91e7bc5df645d1 /gettext-tools/tests/msgexec-5
parent28af453ba63911b5007d92a464e8c9736004634b (diff)
downloadexternal_gettext-70501a1599a3f4052fac1801263d6cc168fb17e0.zip
external_gettext-70501a1599a3f4052fac1801263d6cc168fb17e0.tar.gz
external_gettext-70501a1599a3f4052fac1801263d6cc168fb17e0.tar.bz2
tests: Add test for msgexec plural handling
Diffstat (limited to 'gettext-tools/tests/msgexec-5')
-rwxr-xr-xgettext-tools/tests/msgexec-593
1 files changed, 93 insertions, 0 deletions
diff --git a/gettext-tools/tests/msgexec-5 b/gettext-tools/tests/msgexec-5
new file mode 100755
index 0000000..1b9dac6
--- /dev/null
+++ b/gettext-tools/tests/msgexec-5
@@ -0,0 +1,93 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test msgexec on a PO file with plurals.
+
+cat <<\EOF > mex-test5.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ASCII\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#, c-format
+msgid "'Your command, please?', asked the waiter."
+msgstr "'Votre commande, s'il vous plait', dit le garcon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+#, c-format
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "%d morceaux de gateau"
+
+# Reverse the arguments.
+#, c-format
+msgid "%s is replaced by %s."
+msgstr "%2$s remplace %1$s."
+EOF
+
+cat <<\EOF > mex-test5.sh
+#! /bin/sh
+echo "========================= $MSGEXEC_LOCATION =========================" | LC_ALL=C tr -d '\r'
+if test -n "${MSGEXEC_MSGCTXT+set}"; then
+ echo "context: $MSGEXEC_MSGCTXT" | LC_ALL=C tr -d '\r'
+fi
+cat <<MEOF
+$MSGEXEC_MSGID
+$MSGEXEC_MSGID_PLURAL
+$MSGEXEC_PLURAL_FORM
+---
+MEOF
+cat
+echo | LC_ALL=C tr -d '\r'
+exit 0
+EOF
+chmod a+x mex-test5.sh
+
+: ${MSGEXEC=msgexec}
+LC_ALL=C \
+${MSGEXEC} -i mex-test5.po ./mex-test5.sh > mex-test5.out 2> mex-test5.err
+result=$?
+cat mex-test5.err | grep -v 'warning: Locale charset' | grep -v '^ '
+test $result = 0 || { exit 1; }
+
+cat <<\EOF > mex-test5.ok
+========================= mex-test5.po:2 =========================
+
+
+
+---
+Content-Type: text/plain; charset=ASCII
+Plural-Forms: nplurals=2; plural=(n > 1);
+
+========================= mex-test5.po:8 =========================
+'Your command, please?', asked the waiter.
+
+
+---
+'Votre commande, s'il vous plait', dit le garcon.
+========================= mex-test5.po:14 =========================
+a piece of cake
+%d pieces of cake
+0
+---
+un morceau de gateau
+========================= mex-test5.po:14 =========================
+a piece of cake
+%d pieces of cake
+1
+---
+%d morceaux de gateau
+========================= mex-test5.po:20 =========================
+%s is replaced by %s.
+
+
+---
+%2$s remplace %1$s.
+EOF
+
+: ${DIFF=diff}
+${DIFF} mex-test5.ok mex-test5.out
+result=$?
+
+exit $result