3 # Test of gettext facilities in the Python language.
5 # Note: This test fails with Python 2.3, 2.4 when an UTF-8 locale is present.
6 # It looks like a bug in Python's gettext.py. This here is a quick workaround:
10 trap 'rm -fr $tmpfiles' 1 2 3 15
12 tmpfiles
="$tmpfiles prog.py"
16 gettext.textdomain
('prog')
17 gettext.bindtextdomain
('prog', '.')
19 print
gettext.
gettext("'Your command, please?', asked the waiter.")
20 print
gettext.
gettext("%(oldCurrency)s is replaced by %(newCurrency)s.") \
21 % { 'oldCurrency': "FF", 'newCurrency' : "EUR" }
24 tmpfiles
="$tmpfiles prog.pot"
25 : ${XGETTEXT=xgettext}
26 ${XGETTEXT} -o prog.pot
--omit-header --no-location prog.py
28 tmpfiles
="$tmpfiles prog.ok"
30 msgid "'Your command, please?', asked the waiter."
34 msgid "%(oldCurrency)s is replaced by %(newCurrency)s."
39 ${DIFF} prog.ok prog.pot ||
exit 1
41 tmpfiles
="$tmpfiles fr.po"
45 "Content-Type: text/plain; charset=ISO-8859-1\n"
46 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
48 msgid
"'Your command, please?', asked the waiter."
49 msgstr
"«Votre commande, s'il vous plait», dit le garçon."
51 # Reverse the arguments.
53 msgid
"%(oldCurrency)s is replaced by %(newCurrency)s."
54 msgstr
"%(newCurrency)s remplace %(oldCurrency)s."
57 tmpfiles
="$tmpfiles fr.po.new"
58 : ${MSGMERGE=msgmerge}
59 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
62 ${DIFF} fr.po fr.po.new ||
exit 1
64 tmpfiles
="$tmpfiles fr"
65 test -d fr || mkdir fr
66 test -d fr
/LC_MESSAGES || mkdir fr
/LC_MESSAGES
69 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
71 # Test for presence of python version 2.0 or newer.
72 (python
-V) >/dev
/null
2>/dev
/null \
73 ||
{ rm -fr $tmpfiles; exit 77; }
74 case `python -c 'import sys; print sys.hexversion >= 0x20000F0'` in
76 *) rm -fr $tmpfiles; exit 77;;
79 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
82 «Votre commande
, s
'il vous plait», dit le garçon.
86 «Votre commande, s'il vous plait»
, dit le garçon.
91 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
92 if test $LOCALE_FR != none
; then
93 LANGUAGE
= LC_ALL
=$LOCALE_FR python prog.py
> prog.out ||
exit 1
94 ${DIFF} prog.ok prog.out ||
exit 1
96 if test $LOCALE_FR_UTF8 != none
; then
97 LANGUAGE
= LC_ALL
=$LOCALE_FR_UTF8 python prog.py
> prog.out ||
exit 1
98 ${DIFF} prog.oku prog.out ||
exit 1
100 if test $LOCALE_FR = none
&& test $LOCALE_FR_UTF8 = none
; then
101 rm -fr $tmpfiles; exit 77