xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/tests/lang-clisp (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
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
7tmpfiles=""
8trap 'rm -fr $tmpfiles' 1 2 3 15
9
10tmpfiles="$tmpfiles prog.lisp"
11cat <<\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"))
22EOF
23
24tmpfiles="$tmpfiles prog.pot"
25: ${XGETTEXT=xgettext}
26${XGETTEXT} -o prog.pot --omit-header --no-location prog.lisp
27
28tmpfiles="$tmpfiles prog.ok"
29cat <<EOF > prog.ok
30msgid "'Your command, please?', asked the waiter."
31msgstr ""
32
33#, lisp-format
34msgid "a piece of cake"
35msgid_plural "~D pieces of cake"
36msgstr[0] ""
37msgstr[1] ""
38
39#, lisp-format
40msgid "~A is replaced by ~A."
41msgstr ""
42EOF
43
44: ${DIFF=diff}
45${DIFF} prog.ok prog.pot || exit 1
46
47tmpfiles="$tmpfiles fr.po"
48cat <<\EOF > fr.po
49msgid ""
50msgstr ""
51"Content-Type: text/plain; charset=ISO-8859-1\n"
52"Plural-Forms: nplurals=2; plural=(n > 1);\n"
53
54msgid "'Your command, please?', asked the waiter."
55msgstr "�Votre commande, s'il vous plait�, dit le gar�on."
56
57# Les gateaux allemands sont les meilleurs du monde.
58#, lisp-format
59msgid "a piece of cake"
60msgid_plural "~D pieces of cake"
61msgstr[0] "un morceau de gateau"
62msgstr[1] "~D morceaux de gateau"
63
64# Reverse the arguments.
65#, lisp-format
66msgid "~A is replaced by ~A."
67msgstr "~1@*~A remplace ~0@*~A."
68EOF
69
70tmpfiles="$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
77tmpfiles="$tmpfiles fr"
78test -d fr || mkdir fr
79test -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; }
89version=`clisp --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'`
90case $version in
91  19* | 20*) # older than 2.25
92    echo "Skipping test: clisp version too old"; rm -fr $tmpfiles; exit 77;;
93esac
94version=`echo $version | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/'`
95clisp -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}
104if 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
111fi
112if 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
119fi
120if 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
127fi
128
129tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
130: ${DIFF=diff}
131cat <<\EOF > prog.ok
132Votre commande, s'il vous plait�, dit le gar�on.
1332 morceaux de gateau
134EUR remplace FF.
135EOF
136cat <<\EOF > prog.oku
137«Votre commande, s'il vous plait», dit le garçon.
1382 morceaux de gateau
139EUR remplace FF.
140EOF
141
142: ${LOCALE_FR=fr_FR}
143: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
144if 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
147fi
148if 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
151fi
152
153rm -fr $tmpfiles
154
155exit 0
156