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