3 # Test of gettext facilities in the PHP language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: mod_php4-core.
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles
="$tmpfiles prog.php"
13 setlocale
(LC_ALL
, "");
15 bindtextdomain
("prog", ".");
16 echo _
("'Your command, please?', asked the waiter.");
18 echo printf(_
("%s is replaced by %s."), "FF", "EUR");
23 tmpfiles
="$tmpfiles prog.pot"
24 : ${XGETTEXT=xgettext}
25 ${XGETTEXT} -o prog.pot
--omit-header --no-location prog.php
27 tmpfiles
="$tmpfiles prog.ok"
29 msgid "'Your command, please?', asked the waiter."
33 msgid "%s is replaced by %s."
38 ${DIFF} prog.ok prog.pot ||
exit 1
40 tmpfiles
="$tmpfiles fr.po"
43 msgstr
"Content-Type: text/plain; charset=ISO-8859-1\n"
45 msgid
"'Your command, please?', asked the waiter."
46 msgstr
"«Votre commande, s'il vous plait», dit le garçon."
48 # Reverse the arguments.
50 msgid
"%s is replaced by %s."
51 msgstr
"%2$s remplace %1$s."
54 tmpfiles
="$tmpfiles fr.po.new"
55 : ${MSGMERGE=msgmerge}
56 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
59 ${DIFF} fr.po fr.po.new ||
exit 1
61 tmpfiles
="$tmpfiles fr"
62 test -d fr || mkdir fr
63 test -d fr
/LC_MESSAGES || mkdir fr
/LC_MESSAGES
66 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
68 # Test for presence of php version 4.0 or newer.
69 case `(php -v) 2>/dev/null` in
71 *) rm -fr $tmpfiles; exit 77;;
74 # Test which of the fr_FR locales are installed.
76 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
77 if test $LOCALE_FR != none
; then
78 LC_ALL
=$LOCALE_FR .
/testlocale
85 if test $LOCALE_FR_UTF8 != none
; then
86 LC_ALL
=$LOCALE_FR_UTF8 .
/testlocale
89 77) LOCALE_FR_UTF8
=none
;;
93 if test $LOCALE_FR = none
&& test $LOCALE_FR_UTF8 = none
; then
94 rm -fr $tmpfiles; exit 77
97 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
100 «Votre commande
, s
'il vous plait», dit le garçon.
103 cat <<\EOF > prog.oku
104 «Votre commande, s'il vous plait»
, dit le garçon.
109 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
110 if test $LOCALE_FR != none
; then
111 LANGUAGE
= LC_ALL
=$LOCALE_FR php
-q prog.php
> prog.out ||
exit 1
112 ${DIFF} prog.ok prog.out ||
exit 1
114 if test $LOCALE_FR_UTF8 != none
; then
115 LANGUAGE
= LC_ALL
=$LOCALE_FR_UTF8 php
-q prog.php
> prog.out ||
exit 1
116 ${DIFF} prog.oku prog.out ||
exit 1