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