1#! /bin/sh 2 3# Test of gettext facilities in the sh language. 4# Assumes an fr_FR locale is installed. 5# Assumes the following packages are installed: bash. 6 7# Note: This test fails on BeOS because there all locales use the UTF-8 8# encoding, even the locale fr_FR, thus the output comes out in UTF-8. 9 10tmpfiles="" 11trap 'rm -fr $tmpfiles' 1 2 3 15 12 13tmpfiles="$tmpfiles prog.sh" 14cat <<\EOF > prog.sh 15#! /bin/sh 16 17n=$1 18 19. gettext.sh 20 21TEXTDOMAIN=prog 22export TEXTDOMAIN 23TEXTDOMAINDIR=. 24export TEXTDOMAINDIR 25 26$echo "`gettext \"'Your command, please?', asked the waiter.\"`" 27 28$echo "`eval_ngettext \"a piece of cake\" \"\\$n pieces of cake\" $n`" 29EOF 30 31tmpfiles="$tmpfiles prog.pot" 32: ${XGETTEXT=xgettext} 33${XGETTEXT} -o prog.pot --omit-header --no-location prog.sh 34 35tmpfiles="$tmpfiles prog.ok" 36cat <<\EOF > prog.ok 37msgid "'Your command, please?', asked the waiter." 38msgstr "" 39 40#, sh-format 41msgid "a piece of cake" 42msgid_plural "$n pieces of cake" 43msgstr[0] "" 44msgstr[1] "" 45EOF 46 47: ${DIFF=diff} 48${DIFF} prog.ok prog.pot || exit 1 49 50tmpfiles="$tmpfiles fr.po" 51cat <<\EOF > fr.po 52msgid "" 53msgstr "" 54"Content-Type: text/plain; charset=ISO-8859-1\n" 55"Plural-Forms: nplurals=2; plural=(n > 1);\n" 56 57msgid "'Your command, please?', asked the waiter." 58msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 59 60# Les gateaux allemands sont les meilleurs du monde. 61#, sh-format 62msgid "a piece of cake" 63msgid_plural "$n pieces of cake" 64msgstr[0] "un morceau de gateau" 65msgstr[1] "$n morceaux de gateau" 66EOF 67 68tmpfiles="$tmpfiles fr.po.new" 69: ${MSGMERGE=msgmerge} 70${MSGMERGE} -q -o fr.po.new fr.po prog.pot 71 72: ${DIFF=diff} 73${DIFF} fr.po fr.po.new || exit 1 74 75tmpfiles="$tmpfiles fr" 76test -d fr || mkdir fr 77test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES 78 79: ${MSGFMT=msgfmt} 80${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po 81 82# Test which of the fr_FR locales are installed. 83: ${LOCALE_FR=fr_FR} 84: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 85if test $LOCALE_FR != none; then 86 LC_ALL=$LOCALE_FR ./testlocale 87 case $? in 88 0) ;; 89 77) LOCALE_FR=none;; 90 *) exit 1;; 91 esac 92fi 93if test $LOCALE_FR_UTF8 != none; then 94 LC_ALL=$LOCALE_FR_UTF8 ./testlocale 95 case $? in 96 0) ;; 97 77) LOCALE_FR_UTF8=none;; 98 *) exit 1;; 99 esac 100fi 101if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 102 if test -f /usr/bin/localedef; then 103 echo "Skipping test: no french locale is installed" 104 else 105 echo "Skipping test: no french locale is supported" 106 fi 107 rm -fr $tmpfiles; exit 77 108fi 109 110tmpfiles="$tmpfiles prog.ok prog.oku prog.out" 111: ${DIFF=diff} 112cat <<\EOF > prog.ok 113�Votre commande, s'il vous plait�, dit le gar�on. 1142 morceaux de gateau 115EOF 116cat <<\EOF > prog.oku 117��Votre commande, s'il vous plait��, dit le gar��on. 1182 morceaux de gateau 119EOF 120 121: ${LOCALE_FR=fr_FR} 122: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 123if test $LOCALE_FR != none; then 124 LANGUAGE= LC_ALL=$LOCALE_FR sh ./prog.sh 2 > prog.out || exit 1 125 ${DIFF} prog.ok prog.out || exit 1 126fi 127if test $LOCALE_FR_UTF8 != none; then 128 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 sh ./prog.sh 2 > prog.out || exit 1 129 ${DIFF} prog.oku prog.out || exit 1 130fi 131 132rm -fr $tmpfiles 133 134exit 0 135