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