1*63eb84d1Schristos#! /bin/sh 2*63eb84d1Schristos 3*63eb84d1Schristos# Test of gettext facilities in the CLISP language. 4*63eb84d1Schristos# Assumes an fr_FR locale is installed. 5*63eb84d1Schristos# Assumes the following packages are installed: clisp. 6*63eb84d1Schristos 7*63eb84d1Schristostmpfiles="" 8*63eb84d1Schristostrap 'rm -fr $tmpfiles' 1 2 3 15 9*63eb84d1Schristos 10*63eb84d1Schristostmpfiles="$tmpfiles prog.lisp" 11*63eb84d1Schristoscat <<\EOF > prog.lisp 12*63eb84d1Schristos(setf (textdomain) "prog") 13*63eb84d1Schristos(setf (textdomaindir "prog") "./") 14*63eb84d1Schristos 15*63eb84d1Schristos(setq n (parse-integer (first *args*))) 16*63eb84d1Schristos 17*63eb84d1Schristos(format t "~A~%" (gettext "'Your command, please?', asked the waiter.")) 18*63eb84d1Schristos 19*63eb84d1Schristos(format t "~@?~%" (ngettext "a piece of cake" "~D pieces of cake" n) n) 20*63eb84d1Schristos 21*63eb84d1Schristos(format t "~A~%" (format nil (gettext "~A is replaced by ~A.") "FF" "EUR")) 22*63eb84d1SchristosEOF 23*63eb84d1Schristos 24*63eb84d1Schristostmpfiles="$tmpfiles prog.pot" 25*63eb84d1Schristos: ${XGETTEXT=xgettext} 26*63eb84d1Schristos${XGETTEXT} -o prog.pot --omit-header --no-location prog.lisp 27*63eb84d1Schristos 28*63eb84d1Schristostmpfiles="$tmpfiles prog.ok" 29*63eb84d1Schristoscat <<EOF > prog.ok 30*63eb84d1Schristosmsgid "'Your command, please?', asked the waiter." 31*63eb84d1Schristosmsgstr "" 32*63eb84d1Schristos 33*63eb84d1Schristos#, lisp-format 34*63eb84d1Schristosmsgid "a piece of cake" 35*63eb84d1Schristosmsgid_plural "~D pieces of cake" 36*63eb84d1Schristosmsgstr[0] "" 37*63eb84d1Schristosmsgstr[1] "" 38*63eb84d1Schristos 39*63eb84d1Schristos#, lisp-format 40*63eb84d1Schristosmsgid "~A is replaced by ~A." 41*63eb84d1Schristosmsgstr "" 42*63eb84d1SchristosEOF 43*63eb84d1Schristos 44*63eb84d1Schristos: ${DIFF=diff} 45*63eb84d1Schristos${DIFF} prog.ok prog.pot || exit 1 46*63eb84d1Schristos 47*63eb84d1Schristostmpfiles="$tmpfiles fr.po" 48*63eb84d1Schristoscat <<\EOF > fr.po 49*63eb84d1Schristosmsgid "" 50*63eb84d1Schristosmsgstr "" 51*63eb84d1Schristos"Content-Type: text/plain; charset=ISO-8859-1\n" 52*63eb84d1Schristos"Plural-Forms: nplurals=2; plural=(n > 1);\n" 53*63eb84d1Schristos 54*63eb84d1Schristosmsgid "'Your command, please?', asked the waiter." 55*63eb84d1Schristosmsgstr "�Votre commande, s'il vous plait�, dit le gar�on." 56*63eb84d1Schristos 57*63eb84d1Schristos# Les gateaux allemands sont les meilleurs du monde. 58*63eb84d1Schristos#, lisp-format 59*63eb84d1Schristosmsgid "a piece of cake" 60*63eb84d1Schristosmsgid_plural "~D pieces of cake" 61*63eb84d1Schristosmsgstr[0] "un morceau de gateau" 62*63eb84d1Schristosmsgstr[1] "~D morceaux de gateau" 63*63eb84d1Schristos 64*63eb84d1Schristos# Reverse the arguments. 65*63eb84d1Schristos#, lisp-format 66*63eb84d1Schristosmsgid "~A is replaced by ~A." 67*63eb84d1Schristosmsgstr "~1@*~A remplace ~0@*~A." 68*63eb84d1SchristosEOF 69*63eb84d1Schristos 70*63eb84d1Schristostmpfiles="$tmpfiles fr.po.new" 71*63eb84d1Schristos: ${MSGMERGE=msgmerge} 72*63eb84d1Schristos${MSGMERGE} -q -o fr.po.new fr.po prog.pot 73*63eb84d1Schristos 74*63eb84d1Schristos: ${DIFF=diff} 75*63eb84d1Schristos${DIFF} fr.po fr.po.new || exit 1 76*63eb84d1Schristos 77*63eb84d1Schristostmpfiles="$tmpfiles fr" 78*63eb84d1Schristostest -d fr || mkdir fr 79*63eb84d1Schristostest -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 80*63eb84d1Schristos 81*63eb84d1Schristos: ${MSGFMT=msgfmt} 82*63eb84d1Schristos${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 83*63eb84d1Schristos 84*63eb84d1Schristos# Test for presence of clisp version 2.28 or newer with gettext support. 85*63eb84d1Schristos# Use clisp for the comparison of the version numbers; neither 'expr' nor 'bc' 86*63eb84d1Schristos# can deal with floating-point numbers. 87*63eb84d1Schristos(clisp --version) >/dev/null 2>/dev/null \ 88*63eb84d1Schristos || { echo "Skipping test: clisp not found"; rm -fr $tmpfiles; exit 77; } 89*63eb84d1Schristosversion=`clisp --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'` 90*63eb84d1Schristoscase $version in 91*63eb84d1Schristos 19* | 20*) # older than 2.25 92*63eb84d1Schristos echo "Skipping test: clisp version too old"; rm -fr $tmpfiles; exit 77;; 93*63eb84d1Schristosesac 94*63eb84d1Schristosversion=`echo $version | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'` 95*63eb84d1Schristosclisp -norc -x "(sys::exit #+GETTEXT (not (>= $version 2.28)) #-GETTEXT t)" \ 96*63eb84d1Schristos >/dev/null \ 97*63eb84d1Schristos || { echo "Skipping test: clisp was built without gettext support" 98*63eb84d1Schristos rm -fr $tmpfiles; exit 77 99*63eb84d1Schristos } 100*63eb84d1Schristos 101*63eb84d1Schristos# Test which of the fr_FR locales are installed. 102*63eb84d1Schristos: ${LOCALE_FR=fr_FR} 103*63eb84d1Schristos: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 104*63eb84d1Schristosif test $LOCALE_FR != none; then 105*63eb84d1Schristos LC_ALL=$LOCALE_FR ./testlocale 106*63eb84d1Schristos case $? in 107*63eb84d1Schristos 0) ;; 108*63eb84d1Schristos 77) LOCALE_FR=none;; 109*63eb84d1Schristos *) exit 1;; 110*63eb84d1Schristos esac 111*63eb84d1Schristosfi 112*63eb84d1Schristosif test $LOCALE_FR_UTF8 != none; then 113*63eb84d1Schristos LC_ALL=$LOCALE_FR_UTF8 ./testlocale 114*63eb84d1Schristos case $? in 115*63eb84d1Schristos 0) ;; 116*63eb84d1Schristos 77) LOCALE_FR_UTF8=none;; 117*63eb84d1Schristos *) exit 1;; 118*63eb84d1Schristos esac 119*63eb84d1Schristosfi 120*63eb84d1Schristosif test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 121*63eb84d1Schristos if test -f /usr/bin/localedef; then 122*63eb84d1Schristos echo "Skipping test: no french locale is installed" 123*63eb84d1Schristos else 124*63eb84d1Schristos echo "Skipping test: no french locale is supported" 125*63eb84d1Schristos fi 126*63eb84d1Schristos rm -fr $tmpfiles; exit 77 127*63eb84d1Schristosfi 128*63eb84d1Schristos 129*63eb84d1Schristostmpfiles="$tmpfiles prog.ok prog.oku prog.out" 130*63eb84d1Schristos: ${DIFF=diff} 131*63eb84d1Schristoscat <<\EOF > prog.ok 132*63eb84d1Schristos�Votre commande, s'il vous plait�, dit le gar�on. 133*63eb84d1Schristos2 morceaux de gateau 134*63eb84d1SchristosEUR remplace FF. 135*63eb84d1SchristosEOF 136*63eb84d1Schristoscat <<\EOF > prog.oku 137*63eb84d1Schristos«Votre commande, s'il vous plait», dit le garçon. 138*63eb84d1Schristos2 morceaux de gateau 139*63eb84d1SchristosEUR remplace FF. 140*63eb84d1SchristosEOF 141*63eb84d1Schristos 142*63eb84d1Schristos: ${LOCALE_FR=fr_FR} 143*63eb84d1Schristos: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 144*63eb84d1Schristosif test $LOCALE_FR != none; then 145*63eb84d1Schristos CLISP_LANGUAGE= LANGUAGE= LC_ALL=$LOCALE_FR clisp prog.lisp 2 > prog.out || exit 1 146*63eb84d1Schristos ${DIFF} prog.ok prog.out || exit 1 147*63eb84d1Schristosfi 148*63eb84d1Schristosif test $LOCALE_FR_UTF8 != none; then 149*63eb84d1Schristos CLISP_LANGUAGE= LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 clisp prog.lisp 2 > prog.out || exit 1 150*63eb84d1Schristos ${DIFF} prog.oku prog.out || exit 1 151*63eb84d1Schristosfi 152*63eb84d1Schristos 153*63eb84d1Schristosrm -fr $tmpfiles 154*63eb84d1Schristos 155*63eb84d1Schristosexit 0 156