1#! /bin/sh 2 3# Test of gettext facilities in the guile implementation of Scheme. 4# Assumes an fr_FR locale is installed. 5# Assumes the following packages are installed: guile. 6 7tmpfiles="" 8trap 'rm -fr $tmpfiles' 1 2 3 15 9 10tmpfiles="$tmpfiles prog.scm" 11cat <<\EOF > prog.scm 12(use-modules (ice-9 format)) 13 14(setlocale LC_ALL "") 15(textdomain "prog") 16(bindtextdomain "prog" ".") 17 18(define n (string->number (list-ref (command-line) 1))) 19 20(format #t "~A~%" (gettext "'Your command, please?', asked the waiter.")) 21 22(format #t "~@?~%" (ngettext "a piece of cake" "~D pieces of cake" n) n) 23 24(format #t "~A~%" (format #f (gettext "~A is replaced by ~A.") "FF" "EUR")) 25EOF 26 27tmpfiles="$tmpfiles prog.pot" 28: ${XGETTEXT=xgettext} 29${XGETTEXT} -o prog.pot --omit-header --no-location prog.scm 30 31tmpfiles="$tmpfiles prog.ok" 32cat <<EOF > prog.ok 33msgid "'Your command, please?', asked the waiter." 34msgstr "" 35 36#, scheme-format 37msgid "a piece of cake" 38msgid_plural "~D pieces of cake" 39msgstr[0] "" 40msgstr[1] "" 41 42#, scheme-format 43msgid "~A is replaced by ~A." 44msgstr "" 45EOF 46 47: ${DIFF=diff} 48${DIFF} prog.ok prog.pot || exit 1 49 50tmpfiles="$tmpfiles fr.po" 51cat <<\EOF > fr.po 52msgid "" 53msgstr "" 54"Content-Type: text/plain; charset=ISO-8859-1\n" 55"Plural-Forms: nplurals=2; plural=(n > 1);\n" 56 57msgid "'Your command, please?', asked the waiter." 58msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 59 60# Les gateaux allemands sont les meilleurs du monde. 61#, scheme-format 62msgid "a piece of cake" 63msgid_plural "~D pieces of cake" 64msgstr[0] "un morceau de gateau" 65msgstr[1] "~D morceaux de gateau" 66 67# Reverse the arguments. 68#, scheme-format 69msgid "~A is replaced by ~A." 70msgstr "~1@*~A remplace ~0@*~A." 71EOF 72 73tmpfiles="$tmpfiles fr.po.new" 74: ${MSGMERGE=msgmerge} 75${MSGMERGE} -q -o fr.po.new fr.po prog.pot 76 77: ${DIFF=diff} 78${DIFF} fr.po fr.po.new || exit 1 79 80tmpfiles="$tmpfiles fr" 81test -d fr || mkdir fr 82test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 83 84: ${MSGFMT=msgfmt} 85${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 86 87# Test for presence of guile version 1.7 or newer. 88(guile --version) >/dev/null 2>/dev/null \ 89 || { echo "Skipping test: guile not found"; rm -fr $tmpfiles; exit 77; } 90case `guile --version | sed -e 1q | sed -e 's/^[^0-9]*//'` in 91 0.* | 1.[0-6] | 1.[0-6].* ) 92 echo "Skipping test: guile version too old"; rm -fr $tmpfiles; exit 77;; 93esac 94 95# Test which of the fr_FR locales are installed. 96: ${LOCALE_FR=fr_FR} 97: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 98if test $LOCALE_FR != none; then 99 LC_ALL=$LOCALE_FR ./testlocale 100 case $? in 101 0) ;; 102 77) LOCALE_FR=none;; 103 *) exit 1;; 104 esac 105fi 106if test $LOCALE_FR_UTF8 != none; then 107 LC_ALL=$LOCALE_FR_UTF8 ./testlocale 108 case $? in 109 0) ;; 110 77) LOCALE_FR_UTF8=none;; 111 *) exit 1;; 112 esac 113fi 114if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 115 if test -f /usr/bin/localedef; then 116 echo "Skipping test: no french locale is installed" 117 else 118 echo "Skipping test: no french locale is supported" 119 fi 120 rm -fr $tmpfiles; exit 77 121fi 122 123tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 124: ${DIFF=diff} 125cat <<\EOF > prog.ok 126�Votre commande, s'il vous plait�, dit le gar�on. 1272 morceaux de gateau 128EUR remplace FF. 129EOF 130cat <<\EOF > prog.oku 131��Votre commande, s'il vous plait��, dit le gar��on. 1322 morceaux de gateau 133EUR remplace FF. 134EOF 135 136: ${LOCALE_FR=fr_FR} 137: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 138if test $LOCALE_FR != none; then 139 LANGUAGE= LC_ALL=$LOCALE_FR guile -s prog.scm 2 > prog.out || exit 1 140 ${DIFF} prog.ok prog.out || exit 1 141fi 142if test $LOCALE_FR_UTF8 != none; then 143 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 guile -s prog.scm 2 > prog.out || exit 1 144 ${DIFF} prog.oku prog.out || exit 1 145fi 146 147rm -fr $tmpfiles 148 149exit 0 150