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.
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles
="$tmpfiles prog.st"
12 PackageLoader fileInPackage
: 'I18N' !
14 Object subclass
: #Main
15 instanceVariableNames
: ''
16 classVariableNames
: 'NLS'
20 !Main methodsFor
: 'running'!
23 NLS
:= I18N Locale default messages domain
: 'prog' localeDirectory
: '.'.
26 (NLS ?
'''Your command, please?'', asked the waiter.').
28 ((NLS
at: 'a piece of cake' plural
: '%1 pieces of cake' with
: n
) bindWith
: n
).
30 ((NLS ?
'%1 is replaced by %2.') bindWith
: 'FF' with
: 'EUR').
!
36 tmpfiles
="$tmpfiles prog.pot"
37 : ${XGETTEXT=xgettext}
38 ${XGETTEXT} -o prog.pot
--omit-header --no-location prog.st
40 tmpfiles
="$tmpfiles prog.ok"
42 msgid "'Your command, please?', asked the waiter."
46 msgid "a piece of cake"
47 msgid_plural "%1 pieces of cake"
52 msgid "%1 is replaced by %2."
57 ${DIFF} prog.ok prog.pot ||
exit 1
59 tmpfiles
="$tmpfiles fr.po"
63 "Content-Type: text/plain; charset=ISO-8859-1\n"
64 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
66 msgid
"'Your command, please?', asked the waiter."
67 msgstr
"«Votre commande, s'il vous plait», dit le garçon."
69 # Les gateaux allemands sont les meilleurs du monde.
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"
76 # Reverse the arguments.
78 msgid
"%1 is replaced by %2."
79 msgstr
"%2 remplace %1."
82 tmpfiles
="$tmpfiles fr.po.new"
83 : ${MSGMERGE=msgmerge}
84 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
87 ${DIFF} fr.po fr.po.new ||
exit 1
89 tmpfiles
="$tmpfiles fr"
90 test -d fr || mkdir fr
91 test -d fr
/LC_MESSAGES || mkdir fr
/LC_MESSAGES
94 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
96 # Test for presence of gst version 2.0.6 or newer.
97 (gst
--version) >/dev
/null
2>/dev
/null \
98 ||
{ 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 rm -fr $tmpfiles; exit 77;;
104 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
108 «Votre commande
, s
'il vous plait», dit le garçon.
112 cat <<\EOF > prog.oku
114 «Votre commande, s'il vous plait»
, dit le garçon.
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
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
129 if test $LOCALE_FR = none
&& test $LOCALE_FR_UTF8 = none
; then
130 rm -fr $tmpfiles; exit 77