1 1.1 christos #! /bin/sh 2 1.1 christos 3 1.1 christos # Test of gettext facilities in the GNU smalltalk language. 4 1.1 christos # Assumes an fr_FR locale is installed. 5 1.1 christos # Assumes the following packages are installed: smalltalk. 6 1.1 christos 7 1.1 christos tmpfiles="" 8 1.1 christos trap 'rm -fr $tmpfiles' 1 2 3 15 9 1.1 christos 10 1.1 christos tmpfiles="$tmpfiles prog.st" 11 1.1 christos cat <<\EOF > prog.st 12 1.1 christos PackageLoader fileInPackage: 'I18N' ! 13 1.1 christos 14 1.1 christos Object subclass: #Main 15 1.1 christos instanceVariableNames: '' 16 1.1 christos classVariableNames: 'NLS' 17 1.1 christos poolDictionaries: '' 18 1.1 christos category: 'Program' 19 1.1 christos ! 20 1.1 christos !Main methodsFor: 'running'! 21 1.1 christos run 22 1.1 christos | n | 23 1.1 christos NLS := I18N Locale default messages domain: 'prog' localeDirectory: '.'. 24 1.1 christos n := 2. 25 1.1 christos Transcript showCr: 26 1.1 christos (NLS ? '''Your command, please?'', asked the waiter.'). 27 1.1 christos Transcript showCr: 28 1.1 christos ((NLS at: 'a piece of cake' plural: '%1 pieces of cake' with: n) bindWith: n). 29 1.1 christos Transcript showCr: 30 1.1 christos ((NLS ? '%1 is replaced by %2.') bindWith: 'FF' with: 'EUR').! 31 1.1 christos ! 32 1.1 christos 33 1.1 christos Main new run! 34 1.1 christos EOF 35 1.1 christos 36 1.1 christos tmpfiles="$tmpfiles prog.pot" 37 1.1 christos : ${XGETTEXT=xgettext} 38 1.1 christos ${XGETTEXT} -o prog.pot --omit-header --no-location prog.st 39 1.1 christos 40 1.1 christos tmpfiles="$tmpfiles prog.ok" 41 1.1 christos cat <<EOF > prog.ok 42 1.1 christos msgid "'Your command, please?', asked the waiter." 43 1.1 christos msgstr "" 44 1.1 christos 45 1.1 christos #, smalltalk-format 46 1.1 christos msgid "a piece of cake" 47 1.1 christos msgid_plural "%1 pieces of cake" 48 1.1 christos msgstr[0] "" 49 1.1 christos msgstr[1] "" 50 1.1 christos 51 1.1 christos #, smalltalk-format 52 1.1 christos msgid "%1 is replaced by %2." 53 1.1 christos msgstr "" 54 1.1 christos EOF 55 1.1 christos 56 1.1 christos : ${DIFF=diff} 57 1.1 christos ${DIFF} prog.ok prog.pot || exit 1 58 1.1 christos 59 1.1 christos tmpfiles="$tmpfiles fr.po" 60 1.1 christos cat <<\EOF > fr.po 61 1.1 christos msgid "" 62 1.1 christos msgstr "" 63 1.1 christos "Content-Type: text/plain; charset=ISO-8859-1\n" 64 1.1 christos "Plural-Forms: nplurals=2; plural=(n > 1);\n" 65 1.1 christos 66 1.1 christos msgid "'Your command, please?', asked the waiter." 67 1.1 christos msgstr "Votre commande, s'il vous plait, dit le garon." 68 1.1 christos 69 1.1 christos # Les gateaux allemands sont les meilleurs du monde. 70 1.1 christos #, smalltalk-format 71 1.1 christos msgid "a piece of cake" 72 1.1 christos msgid_plural "%1 pieces of cake" 73 1.1 christos msgstr[0] "un morceau de gateau" 74 1.1 christos msgstr[1] "%1 morceaux de gateau" 75 1.1 christos 76 1.1 christos # Reverse the arguments. 77 1.1 christos #, smalltalk-format 78 1.1 christos msgid "%1 is replaced by %2." 79 1.1 christos msgstr "%2 remplace %1." 80 1.1 christos EOF 81 1.1 christos 82 1.1 christos tmpfiles="$tmpfiles fr.po.new" 83 1.1 christos : ${MSGMERGE=msgmerge} 84 1.1 christos ${MSGMERGE} -q -o fr.po.new fr.po prog.pot 85 1.1 christos 86 1.1 christos : ${DIFF=diff} 87 1.1 christos ${DIFF} fr.po fr.po.new || exit 1 88 1.1 christos 89 1.1 christos tmpfiles="$tmpfiles fr" 90 1.1 christos test -d fr || mkdir fr 91 1.1 christos test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 92 1.1 christos 93 1.1 christos : ${MSGFMT=msgfmt} 94 1.1 christos ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 95 1.1 christos 96 1.1 christos # Test for presence of gst version 2.0.6 or newer. 97 1.1 christos (gst --version) >/dev/null 2>/dev/null \ 98 1.1 christos || { echo "Skipping test: gst not found"; rm -fr $tmpfiles; exit 77; } 99 1.1 christos case `gst --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'` in 100 1.1 christos 0.* | 1.* | 2.0 | 2.0.[0-5] | 2.1 | 2.1.[0-1]) 101 1.1 christos echo "Skipping test: gst version too old"; rm -fr $tmpfiles; exit 77;; 102 1.1 christos esac 103 1.1 christos 104 1.1 christos tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 105 1.1 christos : ${DIFF=diff} 106 1.1 christos cat <<\EOF > prog.ok 107 1.1 christos Loading package I18N 108 1.1 christos Votre commande, s'il vous plait, dit le garon. 109 1.1 christos 2 morceaux de gateau 110 1.1 christos EUR remplace FF. 111 1.1 christos EOF 112 1.1 christos cat <<\EOF > prog.oku 113 1.1 christos Loading package I18N 114 1.1 christos Votre commande, s'il vous plait, dit le garon. 115 1.1 christos 2 morceaux de gateau 116 1.1 christos EUR remplace FF. 117 1.1 christos EOF 118 1.1 christos 119 1.1 christos : ${LOCALE_FR=fr_FR} 120 1.1 christos : ${LOCALE_FR_UTF8=fr_FR.UTF-8} 121 1.1 christos if test $LOCALE_FR != none; then 122 1.1 christos LANGUAGE= LC_ALL=$LOCALE_FR gst -Q prog.st > prog.out || exit 1 123 1.1 christos ${DIFF} prog.ok prog.out || exit 1 124 1.1 christos fi 125 1.1 christos if test $LOCALE_FR_UTF8 != none; then 126 1.1 christos LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gst -Q prog.st > prog.out || exit 1 127 1.1 christos ${DIFF} prog.oku prog.out || exit 1 128 1.1 christos fi 129 1.1 christos if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 130 1.1 christos if test -f /usr/bin/localedef; then 131 1.1 christos echo "Skipping test: no french locale is installed" 132 1.1 christos else 133 1.1 christos echo "Skipping test: no french locale is supported" 134 1.1 christos fi 135 1.1 christos rm -fr $tmpfiles; exit 77 136 1.1 christos fi 137 1.1 christos 138 1.1 christos rm -fr $tmpfiles 139 1.1 christos 140 1.1 christos exit 0 141