1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src ../../gettext-runtime/src 3 4# Test of gettext facilities in the sh language. 5# Assumes an fr_FR locale is installed. 6# Assumes the following packages are installed: bash. 7 8# Note: This test fails on BeOS because there all locales use the UTF-8 9# encoding, even the locale fr_FR, thus the output comes out in UTF-8. 10 11# This test fails if the gettext package was configured with --disable-nls, 12# because in this case the gettext-runtime/src/gettext program does not do 13# any message catalog lookups. 14 15cat <<\EOF > prog.sh 16#! /bin/sh 17 18n=$1 19 20. gettext.sh 21 22TEXTDOMAIN=prog 23export TEXTDOMAIN 24TEXTDOMAINDIR=. 25export TEXTDOMAINDIR 26 27$echo "`gettext \"'Your command, please?', asked the waiter.\"`" 28 29$echo "`eval_ngettext \"a piece of cake\" \"\\$n pieces of cake\" $n`" 30 31$echo "`gettext -c File \"Open\"`" 32 33$echo "`gettext --context File \"Close\"`" 34 35$echo "`gettext --context=File \"Save\"`" 36 37$echo "`eval_npgettext File \"\\$n file open\" \"\\$n files open\" $n`" 38EOF 39 40: ${XGETTEXT=xgettext} 41${XGETTEXT} -o prog.tmp --omit-header --no-location prog.sh || Exit 1 42LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || Exit 1 43 44cat <<\EOF > prog.ok 45msgid "'Your command, please?', asked the waiter." 46msgstr "" 47 48#, sh-format 49msgid "a piece of cake" 50msgid_plural "$n pieces of cake" 51msgstr[0] "" 52msgstr[1] "" 53 54msgctxt "File" 55msgid "Open" 56msgstr "" 57 58msgctxt "File" 59msgid "Close" 60msgstr "" 61 62msgctxt "File" 63msgid "Save" 64msgstr "" 65 66#, sh-format 67msgctxt "File" 68msgid "$n file open" 69msgid_plural "$n files open" 70msgstr[0] "" 71msgstr[1] "" 72EOF 73 74: ${DIFF=diff} 75${DIFF} prog.ok prog.pot || Exit 1 76 77cat <<\EOF > fr.po 78msgid "" 79msgstr "" 80"Content-Type: text/plain; charset=ISO-8859-1\n" 81"Plural-Forms: nplurals=2; plural=(n > 1);\n" 82 83msgid "'Your command, please?', asked the waiter." 84msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 85 86# Les gateaux allemands sont les meilleurs du monde. 87#, sh-format 88msgid "a piece of cake" 89msgid_plural "$n pieces of cake" 90msgstr[0] "un morceau de gateau" 91msgstr[1] "$n morceaux de gateau" 92 93msgctxt "File" 94msgid "Open" 95msgstr "Ouvrir" 96 97msgctxt "File" 98msgid "Close" 99msgstr "Fermer" 100 101msgctxt "File" 102msgid "Save" 103msgstr "Sauvegarder" 104 105#, sh-format 106msgctxt "File" 107msgid "$n file open" 108msgid_plural "$n files open" 109msgstr[0] "$n fichier ouvert" 110msgstr[1] "$n fichiers ouverts" 111EOF 112 113: ${MSGMERGE=msgmerge} 114${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || Exit 1 115LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || Exit 1 116 117: ${DIFF=diff} 118${DIFF} fr.po fr.po.new || Exit 1 119 120test -d fr || mkdir fr 121test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 122 123: ${MSGFMT=msgfmt} 124${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 125 126# Test which of the fr_FR locales are installed. 127: ${LOCALE_FR=fr_FR} 128: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 129if test $LOCALE_FR != none; then 130 LC_ALL=$LOCALE_FR ../testlocale 131 case $? in 132 0) ;; 133 77) LOCALE_FR=none;; 134 *) Exit 1;; 135 esac 136fi 137if test $LOCALE_FR_UTF8 != none; then 138 LC_ALL=$LOCALE_FR_UTF8 ../testlocale 139 case $? in 140 0) ;; 141 77) LOCALE_FR_UTF8=none;; 142 *) Exit 1;; 143 esac 144fi 145if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 146 if test -f /usr/bin/localedef; then 147 echo "Skipping test: no french locale is installed" 148 else 149 echo "Skipping test: no french locale is supported" 150 fi 151 Exit 77 152fi 153 154: ${DIFF=diff} 155cat <<\EOF > prog.ok 156�Votre commande, s'il vous plait�, dit le gar�on. 1572 morceaux de gateau 158Ouvrir 159Fermer 160Sauvegarder 1612 fichiers ouverts 162EOF 163cat <<\EOF > prog.oku 164«Votre commande, s'il vous plait», dit le garçon. 1652 morceaux de gateau 166Ouvrir 167Fermer 168Sauvegarder 1692 fichiers ouverts 170EOF 171 172: ${LOCALE_FR=fr_FR} 173: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 174if test $LOCALE_FR != none; then 175 prepare_locale_ fr $LOCALE_FR 176 LANGUAGE= LC_ALL=$LOCALE_FR sh ./prog.sh 2 > prog.out || Exit 1 177 ${DIFF} prog.ok prog.out || Exit 1 178fi 179if test $LOCALE_FR_UTF8 != none; then 180 prepare_locale_ fr $LOCALE_FR_UTF8 181 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 sh ./prog.sh 2 > prog.out || Exit 1 182 ${DIFF} prog.oku prog.out || Exit 1 183fi 184 185Exit 0 186