lang-guile revision 1.1 1 #! /bin/sh
2
3 # Test of gettext facilities in the guile implementation of Scheme.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: guile.
6
7 tmpfiles=""
8 trap 'rm -fr $tmpfiles' 1 2 3 15
9
10 tmpfiles="$tmpfiles prog.scm"
11 cat <<\EOF > prog.scm
12 (use-modules (ice-9 format))
13
14 (setlocale LC_ALL "")
15 (textdomain "prog")
16 (bindtextdomain "prog" ".")
17
18 (define n (string->number (list-ref (command-line) 1)))
19
20 (format #t "~A~%" (gettext "'Your command, please?', asked the waiter."))
21
22 (format #t "~@?~%" (ngettext "a piece of cake" "~D pieces of cake" n) n)
23
24 (format #t "~A~%" (format #f (gettext "~A is replaced by ~A.") "FF" "EUR"))
25 EOF
26
27 tmpfiles="$tmpfiles prog.pot"
28 : ${XGETTEXT=xgettext}
29 ${XGETTEXT} -o prog.pot --omit-header --no-location prog.scm
30
31 tmpfiles="$tmpfiles prog.ok"
32 cat <<EOF > prog.ok
33 msgid "'Your command, please?', asked the waiter."
34 msgstr ""
35
36 #, scheme-format
37 msgid "a piece of cake"
38 msgid_plural "~D pieces of cake"
39 msgstr[0] ""
40 msgstr[1] ""
41
42 #, scheme-format
43 msgid "~A is replaced by ~A."
44 msgstr ""
45 EOF
46
47 : ${DIFF=diff}
48 ${DIFF} prog.ok prog.pot || exit 1
49
50 tmpfiles="$tmpfiles fr.po"
51 cat <<\EOF > 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 garon."
59
60 # Les gateaux allemands sont les meilleurs du monde.
61 #, scheme-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 #, scheme-format
69 msgid "~A is replaced by ~A."
70 msgstr "~1@*~A remplace ~0@*~A."
71 EOF
72
73 tmpfiles="$tmpfiles fr.po.new"
74 : ${MSGMERGE=msgmerge}
75 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
76
77 : ${DIFF=diff}
78 ${DIFF} fr.po fr.po.new || exit 1
79
80 tmpfiles="$tmpfiles fr"
81 test -d fr || mkdir fr
82 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
83
84 : ${MSGFMT=msgfmt}
85 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
86
87 # Test for presence of guile version 1.7 or newer.
88 (guile --version) >/dev/null 2>/dev/null \
89 || { echo "Skipping test: guile not found"; rm -fr $tmpfiles; exit 77; }
90 case `guile --version | sed -e 1q | sed -e 's/^[^0-9]*//'` in
91 0.* | 1.[0-6] | 1.[0-6].* )
92 echo "Skipping test: guile version too old"; rm -fr $tmpfiles; exit 77;;
93 esac
94
95 # Test which of the fr_FR locales are installed.
96 : ${LOCALE_FR=fr_FR}
97 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
98 if 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
105 fi
106 if 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
113 fi
114 if 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 rm -fr $tmpfiles; exit 77
121 fi
122
123 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
124 : ${DIFF=diff}
125 cat <<\EOF > prog.ok
126 Votre commande, s'il vous plait, dit le garon.
127 2 morceaux de gateau
128 EUR remplace FF.
129 EOF
130 cat <<\EOF > prog.oku
131 Votre commande, s'il vous plait, dit le garon.
132 2 morceaux de gateau
133 EUR remplace FF.
134 EOF
135
136 : ${LOCALE_FR=fr_FR}
137 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
138 if test $LOCALE_FR != none; then
139 LANGUAGE= LC_ALL=$LOCALE_FR guile -s prog.scm 2 > prog.out || exit 1
140 ${DIFF} prog.ok prog.out || exit 1
141 fi
142 if test $LOCALE_FR_UTF8 != none; then
143 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 guile -s prog.scm 2 > prog.out || exit 1
144 ${DIFF} prog.oku prog.out || exit 1
145 fi
146
147 rm -fr $tmpfiles
148
149 exit 0
150