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 7tmpfiles="" 8trap 'rm -fr $tmpfiles' 1 2 3 15 9 10tmpfiles="$tmpfiles prog.st" 11cat <<\EOF > prog.st 12PackageLoader fileInPackage: 'I18N' ! 13 14Object subclass: #Main 15 instanceVariableNames: '' 16 classVariableNames: 'NLS' 17 poolDictionaries: '' 18 category: 'Program' 19! 20!Main methodsFor: 'running'! 21run 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 33Main new run! 34EOF 35 36tmpfiles="$tmpfiles prog.pot" 37: ${XGETTEXT=xgettext} 38${XGETTEXT} -o prog.pot --omit-header --no-location prog.st 39 40tmpfiles="$tmpfiles prog.ok" 41cat <<EOF > prog.ok 42msgid "'Your command, please?', asked the waiter." 43msgstr "" 44 45#, smalltalk-format 46msgid "a piece of cake" 47msgid_plural "%1 pieces of cake" 48msgstr[0] "" 49msgstr[1] "" 50 51#, smalltalk-format 52msgid "%1 is replaced by %2." 53msgstr "" 54EOF 55 56: ${DIFF=diff} 57${DIFF} prog.ok prog.pot || exit 1 58 59tmpfiles="$tmpfiles fr.po" 60cat <<\EOF > fr.po 61msgid "" 62msgstr "" 63"Content-Type: text/plain; charset=ISO-8859-1\n" 64"Plural-Forms: nplurals=2; plural=(n > 1);\n" 65 66msgid "'Your command, please?', asked the waiter." 67msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 68 69# Les gateaux allemands sont les meilleurs du monde. 70#, smalltalk-format 71msgid "a piece of cake" 72msgid_plural "%1 pieces of cake" 73msgstr[0] "un morceau de gateau" 74msgstr[1] "%1 morceaux de gateau" 75 76# Reverse the arguments. 77#, smalltalk-format 78msgid "%1 is replaced by %2." 79msgstr "%2 remplace %1." 80EOF 81 82tmpfiles="$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 89tmpfiles="$tmpfiles fr" 90test -d fr || mkdir fr 91test -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; } 99case `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;; 102esac 103 104tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 105: ${DIFF=diff} 106cat <<\EOF > prog.ok 107Loading package I18N 108�Votre commande, s'il vous plait�, dit le gar�on. 1092 morceaux de gateau 110EUR remplace FF. 111EOF 112cat <<\EOF > prog.oku 113Loading package I18N 114��Votre commande, s'il vous plait��, dit le gar��on. 1152 morceaux de gateau 116EUR remplace FF. 117EOF 118 119: ${LOCALE_FR=fr_FR} 120: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 121if 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 124fi 125if 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 128fi 129if 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 136fi 137 138rm -fr $tmpfiles 139 140exit 0 141