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