3 # Test of gettext facilities in the GNU awk language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: gawk.
7 # Note: This test fails on MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale
8 # but not in the fr_FR.UTF-8 locale. Probably because in the fr_FR locale,
9 # nl_langinfo(CODESET) returns "".
12 trap 'rm -fr $tmpfiles' 1 2 3 15
14 tmpfiles="$tmpfiles prog.awk"
20 print _"'Your command, please?', asked the waiter."
22 printf dcngettext ("a piece of cake", "%d pieces of cake", n) "\n", n
24 printf _"%s is replaced by %s." "\n", "FF", "EUR"
28 tmpfiles="$tmpfiles prog.tmp prog.pot"
29 : ${XGETTEXT=xgettext}
30 ${XGETTEXT} -o prog.tmp --omit-header --no-location prog.awk
31 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
32 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot
33 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
35 tmpfiles="$tmpfiles prog.ok"
37 msgid "'Your command, please?', asked the waiter."
41 msgid "a piece of cake"
42 msgid_plural "%d pieces of cake"
47 msgid "%s is replaced by %s."
52 ${DIFF} prog.ok prog.pot || exit 1
54 tmpfiles="$tmpfiles fr.po"
58 "Content-Type: text/plain; charset=ISO-8859-1\n"
59 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
61 msgid "'Your command, please?', asked the waiter."
62 msgstr "«Votre commande, s'il vous plait», dit le garçon."
64 # Les gateaux allemands sont les meilleurs du monde.
66 msgid "a piece of cake"
67 msgid_plural "%d pieces of cake"
68 msgstr[0] "un morceau de gateau"
69 msgstr[1] "%d morceaux de gateau"
71 # Reverse the arguments.
73 msgid "%s is replaced by %s."
74 msgstr "%2$s remplace %1$s."
77 tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
78 : ${MSGMERGE=msgmerge}
79 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
80 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
81 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new
82 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
85 ${DIFF} fr.po fr.po.new || exit 1
87 tmpfiles="$tmpfiles fr"
88 test -d fr || mkdir fr
89 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
92 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
94 # Test for presence of gawk version 3.1.3 or newer, excluding version 3.1.5.
95 (gawk --version) >/dev/null 2>/dev/null \
96 || { echo "Skipping test: gawk not found"; rm -fr $tmpfiles; exit 77; }
97 case `gawk --version 2>&1 | sed -e 's/^[^0-9]*//'` in
98 0.* | 1.* | 2.* | 3.0* | 3.1.0* | 3.1.1* | 3.1.2* | 3.1.5*)
99 echo "Skipping test: gawk version too old"; rm -fr $tmpfiles; exit 77;;
102 # Test which of the fr_FR locales are installed.
104 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
105 if test $LOCALE_FR != none; then
106 LC_ALL=$LOCALE_FR ./testlocale
113 if test $LOCALE_FR_UTF8 != none; then
114 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
117 77) LOCALE_FR_UTF8=none;;
121 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
122 if test -f /usr/bin/localedef; then
123 echo "Skipping test: no french locale is installed"
125 echo "Skipping test: no french locale is supported"
127 rm -fr $tmpfiles; exit 77
130 # Test that gawk wasn't built with --disable-nls.
132 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
133 if test $LOCALE_FR != none; then
134 LANGUAGE= LC_ALL=$LOCALE_FR gawk --version | grep logiciel > /dev/null
136 echo "Skipping test: gawk was built without i18n support"
137 rm -fr $tmpfiles; exit 77
140 if test $LOCALE_FR_UTF8 != none; then
141 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gawk --version | grep logiciel > /dev/null
143 echo "Skipping test: gawk was built without i18n support"
144 rm -fr $tmpfiles; exit 77
148 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
151 «Votre commande, s'il vous plait», dit le garçon.
155 cat <<\EOF > prog.oku
156 «Votre commande, s'il vous plait», dit le garçon.
162 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
163 if test $LOCALE_FR != none; then
164 LANGUAGE= LC_ALL=$LOCALE_FR gawk -v n=2 -f prog.awk > prog.out || exit 1
165 ${DIFF} prog.ok prog.out || exit 1
167 if test $LOCALE_FR_UTF8 != none; then
168 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gawk -v n=2 -f prog.awk > prog.out || exit 1
169 ${DIFF} prog.oku prog.out || exit 1