2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities (including plural handling) in the Python
7 # Note: This test fails with Python 2.3, 2.4 when an UTF-8 locale is present.
8 # It looks like a bug in Python's gettext.py. This here is a quick workaround:
9 UTF8_LOCALE_UNSUPPORTED=yes
17 gettext.textdomain('prog')
18 gettext.bindtextdomain('prog', '.')
20 print gettext.gettext("'Your command, please?', asked the waiter.")
21 print gettext.ngettext("a piece of cake","%(count)d pieces of cake",n) \
23 print gettext.gettext("%(oldCurrency)s is replaced by %(newCurrency)s.") \
24 % { 'oldCurrency': "FF", 'newCurrency' : "EUR" }
27 : ${XGETTEXT=xgettext}
28 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog2.py || exit 1
29 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
32 msgid "'Your command, please?', asked the waiter."
36 msgid "a piece of cake"
37 msgid_plural "%(count)d pieces of cake"
42 msgid "%(oldCurrency)s is replaced by %(newCurrency)s."
47 ${DIFF} prog.ok prog.pot || exit 1
52 "Content-Type: text/plain; charset=ISO-8859-1\n"
53 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
55 msgid "'Your command, please?', asked the waiter."
56 msgstr "«Votre commande, s'il vous plait», dit le garçon."
58 # Les gateaux allemands sont les meilleurs du monde.
60 msgid "a piece of cake"
61 msgid_plural "%(count)d pieces of cake"
62 msgstr[0] "un morceau de gateau"
63 msgstr[1] "%(count)d morceaux de gateau"
65 # Reverse the arguments.
67 msgid "%(oldCurrency)s is replaced by %(newCurrency)s."
68 msgstr "%(newCurrency)s remplace %(oldCurrency)s."
71 : ${MSGMERGE=msgmerge}
72 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
73 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
76 ${DIFF} fr.po fr.po.new || exit 1
78 test -d fr || mkdir fr
79 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
82 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
84 # Test for presence of python version 2.3 or newer.
85 (python -V) >/dev/null 2>/dev/null \
86 || { echo "Skipping test: python not found"; exit 77; }
87 case `python -c 'import sys; print sys.hexversion >= 0x20300F0'` in
89 *) echo "Skipping test: python version too old"; exit 77;;
94 «Votre commande, s'il vous plait», dit le garçon.
99 «Votre commande, s'il vous plait», dit le garçon.
105 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
106 if test $LOCALE_FR != none; then
107 prepare_locale_ fr $LOCALE_FR
108 LANGUAGE= LC_ALL=$LOCALE_FR python prog2.py 2 > prog.out || exit 1
109 ${DIFF} prog.ok prog.out || exit 1
111 if test -z "$UTF8_LOCALE_UNSUPPORTED"; then
112 if test $LOCALE_FR_UTF8 != none; then
113 prepare_locale_ fr $LOCALE_FR_UTF8
114 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 python prog2.py 2 > prog.out || exit 1
115 ${DIFF} prog.oku prog.out || exit 1
117 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
118 if test -f /usr/bin/localedef; then
119 echo "Skipping test: no french locale is installed"
121 echo "Skipping test: no french locale is supported"
126 if test $LOCALE_FR = none; then
127 if test -f /usr/bin/localedef; then
128 echo "Skipping test: no traditional french locale is installed"
130 echo "Skipping test: no traditional french locale is supported"