3 # Test of gettext facilities in the CLISP language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: clisp.
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles="$tmpfiles prog.lisp"
11 cat <<\EOF > prog.lisp
12 (setf (textdomain) "prog")
13 (setf (textdomaindir "prog") "./l-clisp/")
15 (setq n (parse-integer (first *args*)))
17 (format t "~A~%" (gettext "'Your command, please?', asked the waiter."))
19 (format t "~@?~%" (ngettext "a piece of cake" "~D pieces of cake" n) n)
21 (format t "~A~%" (format nil (gettext "~A is replaced by ~A.") "FF" "EUR"))
24 tmpfiles="$tmpfiles l-clisp-prog.tmp l-clisp-prog.pot"
25 : ${XGETTEXT=xgettext}
26 ${XGETTEXT} -o l-clisp-prog.tmp --omit-header --no-location prog.lisp
27 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
28 LC_ALL=C tr -d '\r' < l-clisp-prog.tmp > l-clisp-prog.pot
29 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
31 tmpfiles="$tmpfiles l-clisp-prog.ok"
32 cat <<EOF > l-clisp-prog.ok
33 msgid "'Your command, please?', asked the waiter."
37 msgid "a piece of cake"
38 msgid_plural "~D pieces of cake"
43 msgid "~A is replaced by ~A."
48 ${DIFF} l-clisp-prog.ok l-clisp-prog.pot || exit 1
50 tmpfiles="$tmpfiles l-clisp-fr.po"
51 cat <<\EOF > l-clisp-fr.po
54 "Content-Type: text/plain; charset=ISO-8859-1\n"
55 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
57 msgid "'Your command, please?', asked the waiter."
58 msgstr "«Votre commande, s'il vous plait», dit le garçon."
60 # Les gateaux allemands sont les meilleurs du monde.
62 msgid "a piece of cake"
63 msgid_plural "~D pieces of cake"
64 msgstr[0] "un morceau de gateau"
65 msgstr[1] "~D morceaux de gateau"
67 # Reverse the arguments.
69 msgid "~A is replaced by ~A."
70 msgstr "~1@*~A remplace ~0@*~A."
73 tmpfiles="$tmpfiles l-clisp-fr.po.tmp l-clisp-fr.po.new"
74 : ${MSGMERGE=msgmerge}
75 ${MSGMERGE} -q -o l-clisp-fr.po.tmp l-clisp-fr.po l-clisp-prog.pot
76 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
77 LC_ALL=C tr -d '\r' < l-clisp-fr.po.tmp > l-clisp-fr.po.new
78 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
81 ${DIFF} l-clisp-fr.po l-clisp-fr.po.new || exit 1
83 tmpfiles="$tmpfiles l-clisp"
84 test -d l-clisp || mkdir l-clisp
85 test -d l-clisp/fr || mkdir l-clisp/fr
86 test -d l-clisp/fr/LC_MESSAGES || mkdir l-clisp/fr/LC_MESSAGES
89 ${MSGFMT} -o l-clisp/fr/LC_MESSAGES/prog.mo l-clisp-fr.po
91 # Test for presence of clisp version 2.28 or newer with gettext support.
92 # Use clisp for the comparison of the version numbers; neither 'expr' nor 'bc'
93 # can deal with floating-point numbers.
94 (clisp --version) >/dev/null 2>/dev/null \
95 || { echo "Skipping test: clisp not found"; rm -fr $tmpfiles; exit 77; }
96 version=`clisp --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'`
98 19* | 20*) # older than 2.25
99 echo "Skipping test: clisp version too old"; rm -fr $tmpfiles; exit 77;;
101 version=`echo $version | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
102 clisp -norc -x "(sys::exit #+GETTEXT (not (>= $version 2.28)) #-GETTEXT t)" \
104 || { echo "Skipping test: clisp was built without gettext support"
105 rm -fr $tmpfiles; exit 77
108 # Test which of the fr_FR locales are installed.
110 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
111 if test $LOCALE_FR != none; then
112 LC_ALL=$LOCALE_FR ./testlocale
119 if test $LOCALE_FR_UTF8 != none; then
120 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
123 77) LOCALE_FR_UTF8=none;;
127 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
128 if test -f /usr/bin/localedef; then
129 echo "Skipping test: no french locale is installed"
131 echo "Skipping test: no french locale is supported"
133 rm -fr $tmpfiles; exit 77
136 tmpfiles="$tmpfiles l-clisp-prog.ok l-clisp-prog.oku l-clisp-prog.out"
138 cat <<\EOF > l-clisp-prog.ok
139 «Votre commande, s'il vous plait», dit le garçon.
143 cat <<\EOF > l-clisp-prog.oku
144 «Votre commande, s'il vous plait», dit le garçon.
150 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
151 if test $LOCALE_FR != none; then
152 CLISP_LANGUAGE= LANGUAGE= LC_ALL=$LOCALE_FR clisp prog.lisp 2 > l-clisp-prog.tmp || exit 1
153 LC_ALL=C tr -d '\r' < l-clisp-prog.tmp > l-clisp-prog.out || exit 1
154 ${DIFF} l-clisp-prog.ok l-clisp-prog.out || exit 1
156 if test $LOCALE_FR_UTF8 != none; then
157 CLISP_LANGUAGE= LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 clisp prog.lisp 2 > l-clisp-prog.tmp || exit 1
158 LC_ALL=C tr -d '\r' < l-clisp-prog.tmp > l-clisp-prog.out || exit 1
159 ${DIFF} l-clisp-prog.oku l-clisp-prog.out || exit 1