Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / lang-smalltalk
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
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.
7
8 cat <<\EOF > prog.st
9 PackageLoader fileInPackage: 'I18N' !
10
11 Object subclass: #Main
12   instanceVariableNames: ''
13   classVariableNames: 'NLS' 
14   poolDictionaries: ''
15   category: 'Program'
16 !
17 !Main methodsFor: 'running'!
18 run
19   | n |
20   NLS := I18N Locale default messages domain: 'prog' localeDirectory: '.'.
21   n := 2.
22   Transcript showCr:
23     (NLS ? '''Your command, please?'', asked the waiter.').
24   Transcript showCr:
25     ((NLS at: 'a piece of cake' plural: '%1 pieces of cake' with: n) bindWith: n).
26   Transcript showCr:
27     ((NLS ? '%1 is replaced by %2.') bindWith: 'FF' with: 'EUR').!
28 !
29
30 Main new run!
31 EOF
32
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
36
37 cat <<EOF > prog.ok
38 msgid "'Your command, please?', asked the waiter."
39 msgstr ""
40
41 #, smalltalk-format
42 msgid "a piece of cake"
43 msgid_plural "%1 pieces of cake"
44 msgstr[0] ""
45 msgstr[1] ""
46
47 #, smalltalk-format
48 msgid "%1 is replaced by %2."
49 msgstr ""
50 EOF
51
52 : ${DIFF=diff}
53 ${DIFF} prog.ok prog.pot || exit 1
54
55 cat <<\EOF > fr.po
56 msgid ""
57 msgstr ""
58 "Content-Type: text/plain; charset=ISO-8859-1\n"
59 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
60
61 msgid "'Your command, please?', asked the waiter."
62 msgstr "«Votre commande, s'il vous plait», dit le garçon."
63
64 # Les gateaux allemands sont les meilleurs du monde.
65 #, smalltalk-format
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"
70
71 # Reverse the arguments.
72 #, smalltalk-format
73 msgid "%1 is replaced by %2."
74 msgstr "%2 remplace %1."
75 EOF
76
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
80
81 : ${DIFF=diff}
82 ${DIFF} fr.po fr.po.new || exit 1
83
84 test -d fr || mkdir fr
85 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
86
87 : ${MSGFMT=msgfmt}
88 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
89
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;;
96 esac
97
98 : ${DIFF=diff}
99 cat <<\EOF > prog.ok
100 «Votre commande, s'il vous plait», dit le garçon.
101 2 morceaux de gateau
102 EUR remplace FF.
103 EOF
104 cat <<\EOF > prog.oku
105 «Votre commande, s'il vous plait», dit le garçon.
106 2 morceaux de gateau
107 EUR remplace FF.
108 EOF
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
116
117 : ${LOCALE_FR=fr_FR}
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; }
126 fi
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; }
134 fi
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"
138   else
139     echo "Skipping test: no french locale is supported"
140   fi
141   exit 77
142 fi
143
144 exit 0