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