2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the PHP language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: mod_php4-core.
10 setlocale (LC_ALL, "");
12 bindtextdomain ("prog", ".");
13 echo _("'Your command, please?', asked the waiter.");
15 printf(_("%s is replaced by %s."), "FF", "EUR");
20 : ${XGETTEXT=xgettext}
21 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog.php || exit 1
22 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
25 msgid "'Your command, please?', asked the waiter."
29 msgid "%s is replaced by %s."
34 ${DIFF} prog.ok prog.pot || exit 1
38 msgstr "Content-Type: text/plain; charset=ISO-8859-1\n"
40 msgid "'Your command, please?', asked the waiter."
41 msgstr "«Votre commande, s'il vous plait», dit le garçon."
43 # Reverse the arguments.
45 msgid "%s is replaced by %s."
46 msgstr "%2$s remplace %1$s."
49 : ${MSGMERGE=msgmerge}
50 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
51 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
54 ${DIFF} fr.po fr.po.new || exit 1
56 test -d fr || mkdir fr
57 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
60 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
62 # Test for presence of php version 4.0 or newer with gettext support.
63 (php -v) >/dev/null 2>/dev/null
65 || { echo "Skipping test: php not found"; exit 77; }
66 case `php -v | sed -n -e 1p | sed -e 's/^[^0-9]*//'` in
68 *) echo "Skipping test: php version too old"; exit 77;;
70 { php -m | grep '^gettext$' >/dev/null; } \
71 || { echo "Skipping test: php was built without gettext support"
75 # Test which of the fr_FR locales are installed.
77 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
78 if test $LOCALE_FR != none; then
79 LC_ALL=$LOCALE_FR ../testlocale
86 if test $LOCALE_FR_UTF8 != none; then
87 LC_ALL=$LOCALE_FR_UTF8 ../testlocale
90 77) LOCALE_FR_UTF8=none;;
94 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
95 if test -f /usr/bin/localedef; then
96 echo "Skipping test: no french locale is installed"
98 echo "Skipping test: no french locale is supported"
105 «Votre commande, s'il vous plait», dit le garçon.
108 cat <<\EOF > prog.oku
109 «Votre commande, s'il vous plait», dit le garçon.
114 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
115 if test $LOCALE_FR != none; then
116 prepare_locale_ fr $LOCALE_FR
117 LANGUAGE= LC_ALL=$LOCALE_FR php -q prog.php > prog.out || exit 1
118 ${DIFF} prog.ok prog.out || exit 1
120 if test $LOCALE_FR_UTF8 != none; then
121 prepare_locale_ fr $LOCALE_FR_UTF8
122 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 php -q prog.php > prog.out || exit 1
123 ${DIFF} prog.oku prog.out || exit 1