No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-php
blob77de6cee8271ee17112b34d55a841e2287a10e83
1 #! /bin/sh
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.
7 tmpfiles=""
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles="$tmpfiles prog.php"
11 cat <<\EOF > prog.php
13 setlocale (LC_ALL, "");
14 textdomain ("prog");
15 bindtextdomain ("prog", ".");
16 echo _("'Your command, please?', asked the waiter.");
17 echo "\n";
18 echo printf(_("%s is replaced by %s."), "FF", "EUR");
19 echo "\n";
21 EOF
23 tmpfiles="$tmpfiles prog.pot"
24 : ${XGETTEXT=xgettext}
25 ${XGETTEXT} -o prog.pot --omit-header --no-location prog.php
27 tmpfiles="$tmpfiles prog.ok"
28 cat <<EOF > prog.ok
29 msgid "'Your command, please?', asked the waiter."
30 msgstr ""
32 #, php-format
33 msgid "%s is replaced by %s."
34 msgstr ""
35 EOF
37 : ${DIFF=diff}
38 ${DIFF} prog.ok prog.pot || exit 1
40 tmpfiles="$tmpfiles fr.po"
41 cat <<\EOF > fr.po
42 msgid ""
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.
49 #, php-format
50 msgid "%s is replaced by %s."
51 msgstr "%2$s remplace %1$s."
52 EOF
54 tmpfiles="$tmpfiles fr.po.new"
55 : ${MSGMERGE=msgmerge}
56 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
58 : ${DIFF=diff}
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
65 : ${MSGFMT=msgfmt}
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
70 [4-9].*) ;;
71 *) rm -fr $tmpfiles; exit 77;;
72 esac
74 # Test which of the fr_FR locales are installed.
75 : ${LOCALE_FR=fr_FR}
76 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
77 if test $LOCALE_FR != none; then
78 LC_ALL=$LOCALE_FR ./testlocale
79 case $? in
80 0) ;;
81 77) LOCALE_FR=none;;
82 *) exit 1;;
83 esac
85 if test $LOCALE_FR_UTF8 != none; then
86 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
87 case $? in
88 0) ;;
89 77) LOCALE_FR_UTF8=none;;
90 *) exit 1;;
91 esac
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"
98 : ${DIFF=diff}
99 cat <<\EOF > prog.ok
100 «Votre commande, s'il vous plait», dit le garçon.
101 EUR remplace FF.
103 cat <<\EOF > prog.oku
104 «Votre commande, s'il vous plait», dit le garçon.
105 EUR remplace FF.
108 : ${LOCALE_FR=fr_FR}
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
119 rm -fr $tmpfiles
121 exit 0