2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the Python language.
6 # Note: This test fails with Python 2.3, 2.4 when an UTF-8 locale is present.
7 # It looks like a bug in Python's gettext.py. This here is a quick workaround:
8 UTF8_LOCALE_UNSUPPORTED=yes
13 gettext.textdomain('prog')
14 gettext.bindtextdomain('prog', '.')
16 print gettext.gettext("'Your command, please?', asked the waiter.")
17 print gettext.gettext("%(oldCurrency)s is replaced by %(newCurrency)s.") \
18 % { 'oldCurrency': "FF", 'newCurrency' : "EUR" }
21 : ${XGETTEXT=xgettext}
22 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog1.py || exit 1
23 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
26 msgid "'Your command, please?', asked the waiter."
30 msgid "%(oldCurrency)s is replaced by %(newCurrency)s."
35 ${DIFF} prog.ok prog.pot || exit 1
40 "Content-Type: text/plain; charset=ISO-8859-1\n"
41 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
43 msgid "'Your command, please?', asked the waiter."
44 msgstr "«Votre commande, s'il vous plait», dit le garçon."
46 # Reverse the arguments.
48 msgid "%(oldCurrency)s is replaced by %(newCurrency)s."
49 msgstr "%(newCurrency)s remplace %(oldCurrency)s."
52 : ${MSGMERGE=msgmerge}
53 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
54 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
57 ${DIFF} fr.po fr.po.new || exit 1
59 test -d fr || mkdir fr
60 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
63 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
65 # Test for presence of python version 2.0 or newer.
66 (python -V) >/dev/null 2>/dev/null \
67 || { echo "Skipping test: python not found"; exit 77; }
68 case `python -c 'import sys; print sys.hexversion >= 0x20000F0'` in
70 *) echo "Skipping test: python version too old"; exit 77;;
75 «Votre commande, s'il vous plait», dit le garçon.
79 «Votre commande, s'il vous plait», dit le garçon.
84 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
85 if test $LOCALE_FR != none; then
86 prepare_locale_ fr $LOCALE_FR
87 LANGUAGE= LC_ALL=$LOCALE_FR python prog1.py > prog.out || exit 1
88 ${DIFF} prog.ok prog.out || exit 1
90 if test -z "$UTF8_LOCALE_UNSUPPORTED"; then
91 if test $LOCALE_FR_UTF8 != none; then
92 prepare_locale_ fr $LOCALE_FR_UTF8
93 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 python prog1.py > prog.out || exit 1
94 ${DIFF} prog.oku prog.out || exit 1
96 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
97 if test -f /usr/bin/localedef; then
98 echo "Skipping test: no french locale is installed"
100 echo "Skipping test: no french locale is supported"
105 if test $LOCALE_FR = none; then
106 if test -f /usr/bin/localedef; then
107 echo "Skipping test: no traditional french locale is installed"
109 echo "Skipping test: no traditional french locale is supported"