• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
8cat <<\EOF > prog.st
9PackageLoader fileInPackage: 'I18N' !
10
11Object subclass: #Main
12  instanceVariableNames: ''
13  classVariableNames: 'NLS'
14  poolDictionaries: ''
15  category: 'Program'
16!
17!Main methodsFor: 'running'!
18run
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
30Main new run!
31EOF
32
33: ${XGETTEXT=xgettext}
34${XGETTEXT} -o prog.tmp --omit-header --no-location prog.st || Exit 1
35LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || Exit 1
36
37cat <<EOF > prog.ok
38msgid "'Your command, please?', asked the waiter."
39msgstr ""
40
41#, smalltalk-format
42msgid "a piece of cake"
43msgid_plural "%1 pieces of cake"
44msgstr[0] ""
45msgstr[1] ""
46
47#, smalltalk-format
48msgid "%1 is replaced by %2."
49msgstr ""
50EOF
51
52: ${DIFF=diff}
53${DIFF} prog.ok prog.pot || Exit 1
54
55cat <<\EOF > fr.po
56msgid ""
57msgstr ""
58"Content-Type: text/plain; charset=ISO-8859-1\n"
59"Plural-Forms: nplurals=2; plural=(n > 1);\n"
60
61msgid "'Your command, please?', asked the waiter."
62msgstr "�Votre commande, s'il vous plait�, dit le gar�on."
63
64# Les gateaux allemands sont les meilleurs du monde.
65#, smalltalk-format
66msgid "a piece of cake"
67msgid_plural "%1 pieces of cake"
68msgstr[0] "un morceau de gateau"
69msgstr[1] "%1 morceaux de gateau"
70
71# Reverse the arguments.
72#, smalltalk-format
73msgid "%1 is replaced by %2."
74msgstr "%2 remplace %1."
75EOF
76
77: ${MSGMERGE=msgmerge}
78${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || Exit 1
79LC_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
84test -d fr || mkdir fr
85test -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; }
93case `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;;
96esac
97
98: ${DIFF=diff}
99cat <<\EOF > prog.ok
100Votre commande, s'il vous plait�, dit le gar�on.
1012 morceaux de gateau
102EUR remplace FF.
103EOF
104cat <<\EOF > prog.oku
105«Votre commande, s'il vous plait», dit le garçon.
1062 morceaux de gateau
107EUR remplace FF.
108EOF
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}
119if 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; }
126fi
127if 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; }
134fi
135if 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
142fi
143
144Exit 0
145