No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-gawk
blobcafa3665c492491e35e45895ccf44c6fdf772395
1 #! /bin/sh
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 "".
11 tmpfiles=""
12 trap 'rm -fr $tmpfiles' 1 2 3 15
14 tmpfiles="$tmpfiles prog.awk"
15 cat <<\EOF > prog.awk
16 BEGIN {
17 TEXTDOMAIN = "prog"
18 bindtextdomain ("./")
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"
26 EOF
28 tmpfiles="$tmpfiles prog.pot"
29 : ${XGETTEXT=xgettext}
30 ${XGETTEXT} -o prog.pot --omit-header --no-location prog.awk
32 tmpfiles="$tmpfiles prog.ok"
33 cat <<EOF > prog.ok
34 msgid "'Your command, please?', asked the waiter."
35 msgstr ""
37 #, awk-format
38 msgid "a piece of cake"
39 msgid_plural "%d pieces of cake"
40 msgstr[0] ""
41 msgstr[1] ""
43 #, awk-format
44 msgid "%s is replaced by %s."
45 msgstr ""
46 EOF
48 : ${DIFF=diff}
49 ${DIFF} prog.ok prog.pot || exit 1
51 tmpfiles="$tmpfiles fr.po"
52 cat <<\EOF > fr.po
53 msgid ""
54 msgstr ""
55 "Content-Type: text/plain; charset=ISO-8859-1\n"
56 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
58 msgid "'Your command, please?', asked the waiter."
59 msgstr "«Votre commande, s'il vous plait», dit le garçon."
61 # Les gateaux allemands sont les meilleurs du monde.
62 #, awk-format
63 msgid "a piece of cake"
64 msgid_plural "%d pieces of cake"
65 msgstr[0] "un morceau de gateau"
66 msgstr[1] "%d morceaux de gateau"
68 # Reverse the arguments.
69 #, awk-format
70 msgid "%s is replaced by %s."
71 msgstr "%2$s remplace %1$s."
72 EOF
74 tmpfiles="$tmpfiles fr.po.new"
75 : ${MSGMERGE=msgmerge}
76 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
78 : ${DIFF=diff}
79 ${DIFF} fr.po fr.po.new || exit 1
81 tmpfiles="$tmpfiles fr"
82 test -d fr || mkdir fr
83 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
85 : ${MSGFMT=msgfmt}
86 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
88 # Test for presence of gawk version 3.1.1 or newer.
89 (gawk --version) >/dev/null 2>/dev/null \
90 || { rm -fr $tmpfiles; exit 77; }
91 case `gawk --version 2>&1 | sed -e 's/^[^0-9]*//'` in
92 0.* | 1.* | 2.* | 3.0* | 3.1.0*)
93 rm -fr $tmpfiles; exit 77;;
94 esac
96 # Test which of the fr_FR locales are installed.
97 : ${LOCALE_FR=fr_FR}
98 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
99 if test $LOCALE_FR != none; then
100 LC_ALL=$LOCALE_FR ./testlocale
101 case $? in
102 0) ;;
103 77) LOCALE_FR=none;;
104 *) exit 1;;
105 esac
107 if test $LOCALE_FR_UTF8 != none; then
108 LC_ALL=$LOCALE_FR_UTF8 ./testlocale
109 case $? in
110 0) ;;
111 77) LOCALE_FR_UTF8=none;;
112 *) exit 1;;
113 esac
115 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
116 rm -fr $tmpfiles; exit 77
119 # Test that gawk wasn't built with --disable-nls.
120 : ${LOCALE_FR=fr_FR}
121 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
122 if test $LOCALE_FR != none; then
123 LANGUAGE= LC_ALL=$LOCALE_FR gawk --version | grep logiciel > /dev/null
124 test $? = 0 || { rm -fr $tmpfiles; exit 77; }
126 if test $LOCALE_FR_UTF8 != none; then
127 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gawk --version | grep logiciel > /dev/null
128 test $? = 0 || { rm -fr $tmpfiles; exit 77; }
131 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
132 : ${DIFF=diff}
133 cat <<\EOF > prog.ok
134 «Votre commande, s'il vous plait», dit le garçon.
135 2 morceaux de gateau
136 EUR remplace FF.
138 cat <<\EOF > prog.oku
139 «Votre commande, s'il vous plait», dit le garçon.
140 2 morceaux de gateau
141 EUR remplace FF.
144 : ${LOCALE_FR=fr_FR}
145 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
146 if test $LOCALE_FR != none; then
147 LANGUAGE= LC_ALL=$LOCALE_FR gawk -v n=2 -f prog.awk > prog.out || exit 1
148 ${DIFF} prog.ok prog.out || exit 1
150 if test $LOCALE_FR_UTF8 != none; then
151 LANGUAGE= LC_ALL=$LOCALE_FR_UTF8 gawk -v n=2 -f prog.awk > prog.out || exit 1
152 ${DIFF} prog.oku prog.out || exit 1
155 rm -fr $tmpfiles
157 exit 0