Imported Upstream version 0.18.3.2
[platform/upstream/gettext.git] / gettext-tools / tests / lang-clisp
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") "./l-clisp/")
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 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; }
30
31 tmpfiles="$tmpfiles l-clisp-prog.ok"
32 cat <<EOF > l-clisp-prog.ok
33 msgid "'Your command, please?', asked the waiter."
34 msgstr ""
35
36 #, lisp-format
37 msgid "a piece of cake"
38 msgid_plural "~D pieces of cake"
39 msgstr[0] ""
40 msgstr[1] ""
41
42 #, lisp-format
43 msgid "~A is replaced by ~A."
44 msgstr ""
45 EOF
46
47 : ${DIFF=diff}
48 ${DIFF} l-clisp-prog.ok l-clisp-prog.pot || exit 1
49
50 tmpfiles="$tmpfiles l-clisp-fr.po"
51 cat <<\EOF > l-clisp-fr.po
52 msgid ""
53 msgstr ""
54 "Content-Type: text/plain; charset=ISO-8859-1\n"
55 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
56
57 msgid "'Your command, please?', asked the waiter."
58 msgstr "«Votre commande, s'il vous plait», dit le garçon."
59
60 # Les gateaux allemands sont les meilleurs du monde.
61 #, lisp-format
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"
66
67 # Reverse the arguments.
68 #, lisp-format
69 msgid "~A is replaced by ~A."
70 msgstr "~1@*~A remplace ~0@*~A."
71 EOF
72
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; }
79
80 : ${DIFF=diff}
81 ${DIFF} l-clisp-fr.po l-clisp-fr.po.new || exit 1
82
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
87
88 : ${MSGFMT=msgfmt}
89 ${MSGFMT} -o l-clisp/fr/LC_MESSAGES/prog.mo l-clisp-fr.po
90
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]*//'`
97 case $version in
98   19* | 20*) # older than 2.25
99     echo "Skipping test: clisp version too old"; rm -fr $tmpfiles; exit 77;;
100 esac
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)" \
103       >/dev/null \
104   || { echo "Skipping test: clisp was built without gettext support"
105        rm -fr $tmpfiles; exit 77
106      }
107
108 # Test which of the fr_FR locales are installed.
109 : ${LOCALE_FR=fr_FR}
110 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
111 if test $LOCALE_FR != none; then
112   LC_ALL=$LOCALE_FR ./testlocale
113   case $? in
114     0) ;;
115     77) LOCALE_FR=none;;
116     *) exit 1;;
117   esac
118 fi
119 if test $LOCALE_FR_UTF8 != none; then
120   LC_ALL=$LOCALE_FR_UTF8 ./testlocale
121   case $? in
122     0) ;;
123     77) LOCALE_FR_UTF8=none;;
124     *) exit 1;;
125   esac
126 fi
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"
130   else
131     echo "Skipping test: no french locale is supported"
132   fi
133   rm -fr $tmpfiles; exit 77
134 fi
135
136 tmpfiles="$tmpfiles l-clisp-prog.ok l-clisp-prog.oku l-clisp-prog.out"
137 : ${DIFF=diff}
138 cat <<\EOF > l-clisp-prog.ok
139 «Votre commande, s'il vous plait», dit le garçon.
140 2 morceaux de gateau
141 EUR remplace FF.
142 EOF
143 cat <<\EOF > l-clisp-prog.oku
144 «Votre commande, s'il vous plait», dit le garçon.
145 2 morceaux de gateau
146 EUR remplace FF.
147 EOF
148
149 : ${LOCALE_FR=fr_FR}
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
155 fi
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
160 fi
161
162 rm -fr $tmpfiles
163
164 exit 0