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