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") "./")
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 prog.pot"
25 : ${XGETTEXT=xgettext}
26 ${XGETTEXT} -o prog.pot
--omit-header --no-location prog.lisp
28 tmpfiles
="$tmpfiles prog.ok"
30 msgid "'Your command, please?', asked the waiter."
34 msgid "a piece of cake"
35 msgid_plural "~D pieces of cake"
40 msgid "~A is replaced by ~A."
45 ${DIFF} prog.ok prog.pot ||
exit 1
47 tmpfiles
="$tmpfiles fr.po"
51 "Content-Type: text/plain; charset=ISO-8859-1\n"
52 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
54 msgid
"'Your command, please?', asked the waiter."
55 msgstr
"«Votre commande, s'il vous plait», dit le garçon."
57 # Les gateaux allemands sont les meilleurs du monde.
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"
64 # Reverse the arguments.
66 msgid
"~A is replaced by ~A."
67 msgstr
"~1@*~A remplace ~0@*~A."
70 tmpfiles
="$tmpfiles fr.po.new"
71 : ${MSGMERGE=msgmerge}
72 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
75 ${DIFF} fr.po fr.po.new ||
exit 1
77 tmpfiles
="$tmpfiles fr"
78 test -d fr || mkdir fr
79 test -d fr
/LC_MESSAGES || mkdir fr
/LC_MESSAGES
82 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
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 ||
{ rm -fr $tmpfiles; exit 77; }
89 version
=`clisp --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'`
91 19* |
20*) # older than 2.25
92 rm -fr $tmpfiles; exit 77;;
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)" \
97 ||
{ rm -fr $tmpfiles; exit 77; }
99 # Test which of the fr_FR locales are installed.
101 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
102 if test $LOCALE_FR != none
; then
103 LC_ALL
=$LOCALE_FR .
/testlocale
110 if test $LOCALE_FR_UTF8 != none
; then
111 LC_ALL
=$LOCALE_FR_UTF8 .
/testlocale
114 77) LOCALE_FR_UTF8
=none
;;
118 if test $LOCALE_FR = none
&& test $LOCALE_FR_UTF8 = none
; then
119 rm -fr $tmpfiles; exit 77
122 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
125 «Votre commande
, s
'il vous plait», dit le garçon.
129 cat <<\EOF > prog.oku
130 «Votre commande, s'il vous plait»
, dit le garçon.
136 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
137 if test $LOCALE_FR != none
; then
138 CLISP_LANGUAGE
= LANGUAGE
= LC_ALL
=$LOCALE_FR clisp prog.lisp
2 > prog.out ||
exit 1
139 ${DIFF} prog.ok prog.out ||
exit 1
141 if test $LOCALE_FR_UTF8 != none
; then
142 CLISP_LANGUAGE
= LANGUAGE
= LC_ALL
=$LOCALE_FR_UTF8 clisp prog.lisp
2 > prog.out ||
exit 1
143 ${DIFF} prog.oku prog.out ||
exit 1