1#! /bin/sh 2 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. 6 7tmpfiles="" 8trap 'rm -fr $tmpfiles' 1 2 3 15 9 10tmpfiles="$tmpfiles prog.php" 11cat <<\EOF > prog.php 12<? 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"; 20?> 21EOF 22 23tmpfiles="$tmpfiles prog.pot" 24: ${XGETTEXT=xgettext} 25${XGETTEXT} -o prog.pot --omit-header --no-location prog.php 26 27tmpfiles="$tmpfiles prog.ok" 28cat <<EOF > prog.ok 29msgid "'Your command, please?', asked the waiter." 30msgstr "" 31 32#, php-format 33msgid "%s is replaced by %s." 34msgstr "" 35EOF 36 37: ${DIFF=diff} 38${DIFF} prog.ok prog.pot || exit 1 39 40tmpfiles="$tmpfiles fr.po" 41cat <<\EOF > fr.po 42msgid "" 43msgstr "Content-Type: text/plain; charset=ISO-8859-1\n" 44 45msgid "'Your command, please?', asked the waiter." 46msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 47 48# Reverse the arguments. 49#, php-format 50msgid "%s is replaced by %s." 51msgstr "%2$s remplace %1$s." 52EOF 53 54tmpfiles="$tmpfiles fr.po.new" 55: ${MSGMERGE=msgmerge} 56${MSGMERGE} -q -o fr.po.new fr.po prog.pot 57 58: ${DIFF=diff} 59${DIFF} fr.po fr.po.new || exit 1 60 61tmpfiles="$tmpfiles fr" 62test -d fr || mkdir fr 63test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 64 65: ${MSGFMT=msgfmt} 66${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 67 68# Test for presence of php version 4.0 or newer. 69case `(php -v) 2>/dev/null` in 70 [4-9].*) ;; 71 *) rm -fr $tmpfiles; exit 77;; 72esac 73 74# Test which of the fr_FR locales are installed. 75: ${LOCALE_FR=fr_FR} 76: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 77if 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 84fi 85if 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 92fi 93if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 94 rm -fr $tmpfiles; exit 77 95fi 96 97tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 98: ${DIFF=diff} 99cat <<\EOF > prog.ok 100�Votre commande, s'il vous plait�, dit le gar�on. 101EUR remplace FF. 102EOF 103cat <<\EOF > prog.oku 104«Votre commande, s'il vous plait», dit le garçon. 105EUR remplace FF. 106EOF 107 108: ${LOCALE_FR=fr_FR} 109: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 110if 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 113fi 114if 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 117fi 118 119rm -fr $tmpfiles 120 121exit 0 122