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