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.pot"
29 : ${XGETTEXT=xgettext}
30 ${XGETTEXT} -o prog.pot
--omit-header --no-location prog.
awk
32 tmpfiles
="$tmpfiles prog.ok"
34 msgid "'Your command, please?', asked the waiter."
38 msgid "a piece of cake"
39 msgid_plural "%d pieces of cake"
44 msgid "%s is replaced by %s."
49 ${DIFF} prog.ok prog.pot ||
exit 1
51 tmpfiles
="$tmpfiles fr.po"
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.
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.
70 msgid
"%s is replaced by %s."
71 msgstr
"%2$s remplace %1$s."
74 tmpfiles
="$tmpfiles fr.po.new"
75 : ${MSGMERGE=msgmerge}
76 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
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
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;;
96 # Test which of the fr_FR locales are installed.
98 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
99 if test $LOCALE_FR != none
; then
100 LC_ALL
=$LOCALE_FR .
/testlocale
107 if test $LOCALE_FR_UTF8 != none
; then
108 LC_ALL
=$LOCALE_FR_UTF8 .
/testlocale
111 77) LOCALE_FR_UTF8
=none
;;
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.
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"
134 «Votre commande
, s
'il vous plait», dit le garçon.
138 cat <<\EOF > prog.oku
139 «Votre commande, s'il vous plait»
, dit le garçon.
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