summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2002-02-06 12:58:55 +0000
committerBruno Haible <bruno@clisp.org>2009-06-22 01:18:01 +0200
commitf34964a1d70413169a0240abbf153ffa810951fb (patch)
tree594c91dcd3b7e1358589ad14f1fb22e5ffa10ab8 /tests
parent86aac5792a798f0bfcc3e4ab992804154369321b (diff)
downloadexternal_gettext-f34964a1d70413169a0240abbf153ffa810951fb.zip
external_gettext-f34964a1d70413169a0240abbf153ffa810951fb.tar.gz
external_gettext-f34964a1d70413169a0240abbf153ffa810951fb.tar.bz2
New Python backend.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/lang-python87
-rwxr-xr-xtests/xgettext-1884
4 files changed, 179 insertions, 1 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 309b0d9..d58af35 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,11 @@
2002-02-02 Bruno Haible <bruno@clisp.org>
+ * xgettext-18: New file.
+ * lang-python: New file.
+ * Makefile.am (TESTS): Add xgettext-18, lang-python.
+
+2002-02-02 Bruno Haible <bruno@clisp.org>
+
* Makefile.am (INCLUDES): Add -I../lib. Needed for builds with
builddir != srcdir on platforms that don't have stdbool.h.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e4c299f..e7e7e33 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,7 @@ TESTS = gettext-1 gettext-2 \
xgettext-1 xgettext-2 xgettext-3 xgettext-4 xgettext-5 xgettext-6 \
xgettext-7 xgettext-8 xgettext-9 xgettext-10 xgettext-11 xgettext-12 \
xgettext-13 xgettext-14 xgettext-15 xgettext-16 xgettext-17 \
+ xgettext-18 \
format-c-1 format-c-2 \
format-elisp-1 format-elisp-2 \
format-java-1 format-java-2 \
@@ -54,7 +55,7 @@ TESTS = gettext-1 gettext-2 \
format-pascal-1 format-pascal-2 \
format-ycp-1 format-ycp-2 \
plural-1 plural-2 \
- lang-c lang-c++ lang-objc lang-clisp lang-elisp lang-librep lang-java lang-pascal lang-ycp lang-po lang-rst \
+ lang-c lang-c++ lang-objc lang-python lang-clisp lang-elisp lang-librep lang-java lang-pascal lang-ycp lang-po lang-rst \
rpath-1a rpath-1b \
rpath-2aaa rpath-2aab rpath-2aac rpath-2aad \
rpath-2aba rpath-2abb rpath-2abc rpath-2abd \
diff --git a/tests/lang-python b/tests/lang-python
new file mode 100755
index 0000000..5d1fd0c
--- /dev/null
+++ b/tests/lang-python
@@ -0,0 +1,87 @@
+#! /bin/sh
+
+# Test of gettext facilities in the Python language.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles prog.py"
+cat <<\EOF > prog.py
+import gettext
+
+gettext.textdomain('prog')
+gettext.bindtextdomain('prog', '.')
+
+print gettext.gettext("'Your command, please?', asked the waiter.")
+print gettext.gettext("%(oldCurrency)s is replaced by %(newCurrency)s.") \
+ % { 'oldCurrency': "FF", 'newCurrency' : "EUR" }
+EOF
+
+tmpfiles="$tmpfiles prog.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -o prog.pot --omit-header --no-location prog.py
+
+tmpfiles="$tmpfiles prog.ok"
+cat <<EOF > prog.ok
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+#, python-format
+msgid "%(oldCurrency)s is replaced by %(newCurrency)s."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} prog.ok prog.pot || exit 1
+
+tmpfiles="$tmpfiles fr.po"
+cat <<\EOF > fr.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+msgid "'Your command, please?', asked the waiter."
+msgstr "«Votre commande, s'il vous plait», dit le garçon."
+
+# Reverse the arguments.
+#, python-format
+msgid "%(oldCurrency)s is replaced by %(newCurrency)s."
+msgstr "%(newCurrency)s remplace %(oldCurrency)s."
+EOF
+
+tmpfiles="$tmpfiles fr.po.new"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o fr.po.new fr.po prog.pot
+
+: ${DIFF=diff}
+${DIFF} fr.po fr.po.new || exit 1
+
+tmpfiles="$tmpfiles fr"
+test -d fr || mkdir fr
+test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
+
+: ${MSGFMT=msgfmt}
+${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
+
+tmpfiles="$tmpfiles prog.ok prog.out"
+: ${DIFF=diff}
+cat <<\EOF > prog.ok
+«Votre commande, s'il vous plait», dit le garçon.
+EUR remplace FF.
+EOF
+
+# Test for presence of python version 2.0 or newer.
+(python -V) >/dev/null 2>/dev/null \
+ || { echo "SKIP: lang-python"; rm -fr $tmpfiles; exit 77; }
+case `python -c 'import sys; print sys.hexversion >= 0x20000F0'` in
+ 1) ;;
+ *) echo "SKIP: lang-python"; rm -fr $tmpfiles; exit 77;;
+esac
+
+LANGUAGE= LC_ALL=fr_FR python prog.py > prog.out || exit 1
+${DIFF} prog.ok prog.out || exit 1
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/tests/xgettext-18 b/tests/xgettext-18
new file mode 100755
index 0000000..f285ada
--- /dev/null
+++ b/tests/xgettext-18
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+# Test of Python support.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles xg-test18.py"
+cat <<\EOF > xg-test18.py
+# interpret_ansic = true, interpret_unicode = false
+_("abc\
+\\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
+
+# interpret_ansic = false, interpret_unicode = false
+_(r"abc\
+\\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
+
+# interpret_ansic = true, interpret_unicode = true
+_(u"abc\
+\\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
+
+# interpret_ansic = false, interpret_unicode = true
+_(ur"abc\
+\\def\'ghi\"jkl\a\b\f\n\r\t\v x\040x\x7ey\u0142\U00010123\N{LATIN SMALL LETTER Z}");
+EOF
+
+tmpfiles="$tmpfiles xg-test18.err xg-test18.tmp xg-test18.pot"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --add-comments --no-location -o xg-test18.tmp xg-test18.py 2>xg-test18.err
+test $? = 0 || { cat xg-test18.err; rm -fr $tmpfiles; exit 1; }
+grep -v 'POT-Creation-Date' < xg-test18.tmp > xg-test18.pot
+
+tmpfiles="$tmpfiles xg-test18.ok"
+cat <<\EOF > xg-test18.ok
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. interpret_ansic = true, interpret_unicode = false
+msgid ""
+"abc\\def'ghi\"jkl\b\f\n"
+"\r\t x x~y\\u0142\\U00010123\\N{LATIN SMALL LETTER Z}"
+msgstr ""
+
+#. interpret_ansic = false, interpret_unicode = false
+msgid ""
+"abc\\\n"
+"\\\\def\\'ghi\\\"jkl\\a\\b\\f\\n\\r\\t\\v x\\040x\\x7ey\\u0142\\U00010123\\N"
+"{LATIN SMALL LETTER Z}"
+msgstr ""
+
+#. interpret_ansic = true, interpret_unicode = true
+msgid ""
+"abc\\def'ghi\"jkl\b\f\n"
+"\r\t x x~yÅ‚ğ„£z"
+msgstr ""
+
+#. interpret_ansic = false, interpret_unicode = true
+msgid ""
+"abc\\\n"
+"\\\\def\\'ghi\\\"jkl\\a\\b\\f\\n\\r\\t\\v x\\040x\\x7eył\\U00010123\\N{LATIN "
+"SMALL LETTER Z}"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-test18.ok xg-test18.pot
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result