2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the GNU smalltalk language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: smalltalk.
9 PackageLoader fileInPackage: 'I18N' !
11 Object subclass: #Main
12 instanceVariableNames: ''
13 classVariableNames: 'NLS'
17 !Main methodsFor: 'running'!
20 NLS := I18N Locale default messages domain: 'prog' localeDirectory: '.'.
23 (NLS ? '''Your command, please?'', asked the waiter.').
25 ((NLS at: 'a piece of cake' plural: '%1 pieces of cake' with: n) bindWith: n).
27 ((NLS ? '%1 is replaced by %2.') bindWith: 'FF' with: 'EUR').!
33 : ${XGETTEXT=xgettext}
34 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog.st || exit 1
35 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
38 msgid "'Your command, please?', asked the waiter."
42 msgid "a piece of cake"
43 msgid_plural "%1 pieces of cake"
48 msgid "%1 is replaced by %2."
53 ${DIFF} prog.ok prog.pot || exit 1
58 "Content-Type: text/plain; charset=ISO-8859-1\n"
59 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
61 msgid "'Your command, please?', asked the waiter."
62 msgstr "«Votre commande, s'il vous plait», dit le garçon."
64 # Les gateaux allemands sont les meilleurs du monde.
66 msgid "a piece of cake"
67 msgid_plural "%1 pieces of cake"
68 msgstr[0] "un morceau de gateau"
69 msgstr[1] "%1 morceaux de gateau"
71 # Reverse the arguments.
73 msgid "%1 is replaced by %2."
74 msgstr "%2 remplace %1."
77 : ${MSGMERGE=msgmerge}
78 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
79 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
82 ${DIFF} fr.po fr.po.new || exit 1
84 test -d fr || mkdir fr
85 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
88 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
90 # Test for presence of gst version 2.0.6 or newer.
91 (gst --version) >/dev/null 2>/dev/null \
92 || { echo "Skipping test: gst not found"; exit 77; }
93 case `gst --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'` in
94 0.* | 1.* | 2.0 | 2.0.[0-5] | 2.1 | 2.1.[0-1])
95 echo "Skipping test: gst version too old"; exit 77;;
100 «Votre commande, s'il vous plait», dit le garçon.
104 cat <<\EOF > prog.oku
105 «Votre commande, s'il vous plait», dit le garçon.
109 # gst versions older than 2.3 also print "Loading package I18N".
110 { echo 'Loading package I18N'; cat prog.ok; } > prog.ok2
111 { echo 'Loading package I18N'; cat prog.oku; } > prog.oku2
112 # gst version 3.0.3 also prints "Loading package Iconv" and
113 # "Loading package I18N".
114 { echo 'Loading package Iconv'; echo 'Loading package I18N'; cat prog.ok; } > prog.ok3
115 { echo 'Loading package Iconv'; echo 'Loading package I18N'; cat prog.oku; } > prog.oku3
118 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
119 if test $LOCALE_FR != none; then
120 prepare_locale_ fr $LOCALE_FR
121 LANGUAGE= LC_ALL=$LOCALE_FR gst -Q prog.st > prog.out || exit 1
122 ${DIFF} prog.ok prog.out > /dev/null ||
123 ${DIFF} prog.ok2 prog.out > /dev/null ||
124 ${DIFF} prog.ok3 prog.out > /dev/null ||
125 { ${DIFF} prog.ok prog.out; exit 1; }
127 if test $LOCALE_FR_UTF8 != none; then
128 prepare_locale_ fr $LOCALE_FR_UTF8
129 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gst -Q prog.st > prog.out || exit 1
130 ${DIFF} prog.oku prog.out > /dev/null ||
131 ${DIFF} prog.oku2 prog.out > /dev/null ||
132 ${DIFF} prog.oku3 prog.out > /dev/null ||
133 { ${DIFF} prog.oku prog.out; exit 1; }
135 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
136 if test -f /usr/bin/localedef; then
137 echo "Skipping test: no french locale is installed"
139 echo "Skipping test: no french locale is supported"