1#! /bin/sh 2. "${srcdir=.}/init.sh"; path_prepend_ . ../src 3 4# Test of gettext facilities in the GNU awk language. 5# Assumes an fr_FR locale is installed. 6# Assumes the following packages are installed: gawk. 7 8# Note: This test fails on MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale 9# but not in the fr_FR.UTF-8 locale. Probably because in the fr_FR locale, 10# nl_langinfo(CODESET) returns "". 11 12cat <<\EOF > prog.awk 13BEGIN { 14 TEXTDOMAIN = "prog" 15 bindtextdomain ("./") 16 17 print _"'Your command, please?', asked the waiter." 18 19 printf dcngettext ("a piece of cake", "%d pieces of cake", n) "\n", n 20 21 printf _"%s is replaced by %s." "\n", "FF", "EUR" 22} 23EOF 24 25: ${XGETTEXT=xgettext} 26${XGETTEXT} -o prog.tmp --omit-header --no-location prog.awk || Exit 1 27LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || Exit 1 28 29cat <<EOF > prog.ok 30msgid "'Your command, please?', asked the waiter." 31msgstr "" 32 33#, awk-format 34msgid "a piece of cake" 35msgid_plural "%d pieces of cake" 36msgstr[0] "" 37msgstr[1] "" 38 39#, awk-format 40msgid "%s is replaced by %s." 41msgstr "" 42EOF 43 44: ${DIFF=diff} 45${DIFF} prog.ok prog.pot || Exit 1 46 47cat <<\EOF > fr.po 48msgid "" 49msgstr "" 50"Content-Type: text/plain; charset=ISO-8859-1\n" 51"Plural-Forms: nplurals=2; plural=(n > 1);\n" 52 53msgid "'Your command, please?', asked the waiter." 54msgstr "�Votre commande, s'il vous plait�, dit le gar�on." 55 56# Les gateaux allemands sont les meilleurs du monde. 57#, awk-format 58msgid "a piece of cake" 59msgid_plural "%d pieces of cake" 60msgstr[0] "un morceau de gateau" 61msgstr[1] "%d morceaux de gateau" 62 63# Reverse the arguments. 64#, awk-format 65msgid "%s is replaced by %s." 66msgstr "%2$s remplace %1$s." 67EOF 68 69: ${MSGMERGE=msgmerge} 70${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || Exit 1 71LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || Exit 1 72 73: ${DIFF=diff} 74${DIFF} fr.po fr.po.new || Exit 1 75 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 for presence of gawk version 3.1.3 or newer, excluding versions 3.1.5 and 4.2.0. 83(gawk --version) >/dev/null 2>/dev/null \ 84 || { echo "Skipping test: gawk not found"; Exit 77; } 85case `gawk --version 2>&1 | sed -e 's/^[^0-9]*//'` in 86 0.* | 1.* | 2.* | 3.0* | 3.1.0* | 3.1.1* | 3.1.2* | 3.1.5* | 4.2.0*) 87 echo "Skipping test: gawk version too old"; Exit 77;; 88esac 89 90# Test which of the fr_FR locales are installed. 91: ${LOCALE_FR=fr_FR} 92: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 93if test $LOCALE_FR != none; then 94 LC_ALL=$LOCALE_FR ../testlocale 95 case $? in 96 0) ;; 97 77) LOCALE_FR=none;; 98 *) Exit 1;; 99 esac 100fi 101if test $LOCALE_FR_UTF8 != none; then 102 LC_ALL=$LOCALE_FR_UTF8 ../testlocale 103 case $? in 104 0) ;; 105 77) LOCALE_FR_UTF8=none;; 106 *) Exit 1;; 107 esac 108fi 109if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then 110 if test -f /usr/bin/localedef; then 111 echo "Skipping test: no french locale is installed" 112 else 113 echo "Skipping test: no french locale is supported" 114 fi 115 Exit 77 116fi 117 118# Test that gawk wasn't built with --disable-nls. 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 gawk --version | grep logiciel > /dev/null 123 test $? = 0 || { 124 echo "Skipping test: gawk was built without i18n support" 125 Exit 77 126 } 127fi 128if test $LOCALE_FR_UTF8 != none; then 129 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gawk --version | grep logiciel > /dev/null 130 test $? = 0 || { 131 echo "Skipping test: gawk was built without i18n support" 132 Exit 77 133 } 134fi 135 136: ${DIFF=diff} 137cat <<\EOF > prog.ok 138�Votre commande, s'il vous plait�, dit le gar�on. 1392 morceaux de gateau 140EUR remplace FF. 141EOF 142cat <<\EOF > prog.oku 143«Votre commande, s'il vous plait», dit le garçon. 1442 morceaux de gateau 145EUR remplace FF. 146EOF 147 148: ${LOCALE_FR=fr_FR} 149: ${LOCALE_FR_UTF8=fr_FR.UTF-8} 150if test $LOCALE_FR != none; then 151 prepare_locale_ fr $LOCALE_FR 152 LANGUAGE= LC_ALL=$LOCALE_FR gawk -v n=2 -f prog.awk > prog.out || Exit 1 153 ${DIFF} prog.ok prog.out || Exit 1 154fi 155if test $LOCALE_FR_UTF8 != none; then 156 prepare_locale_ fr $LOCALE_FR_UTF8 157 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gawk -v n=2 -f prog.awk > prog.out || Exit 1 158 ${DIFF} prog.oku prog.out || Exit 1 159fi 160 161Exit 0 162