2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the C language.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: gcc.
15 #define _(string) gettext (string)
17 int main (int argc, char *argv[])
19 int n = atoi (argv[2]);
21 xsetenv ("LC_ALL", argv[1], 1);
22 if (setlocale (LC_ALL, "") == NULL)
23 /* Couldn't set locale. */
27 bindtextdomain ("prog", ".");
29 printf (_("'Your command, please?', asked the waiter."));
32 printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);
35 printf (_("%s is replaced by %s."), "FF", "EUR");
42 # Put the -I flags before ${CFLAGS} ${CPPFLAGS}, to make sure that libintl.h
43 # is found in the build directory, regardless of -I options present in
44 # ${CFLAGS} or ${CPPFLAGS}.
45 ${CC} -I../.. -I"$abs_top_srcdir"/gnulib-lib -I../../intl ${CFLAGS} \
46 ${CPPFLAGS} -c prog.c || exit 1
48 : ${CONFIG_SHELL=${SHELL-/bin/sh}}
49 ${CONFIG_SHELL} "$top_builddir"/libtool --quiet --tag=CC --mode=link \
50 ${CC} ${CFLAGS} -o prog prog.${OBJEXT} \
51 ../../gnulib-lib/libgettextlib.la ${LDFLAGS} ${LTLIBINTL} \
54 : ${XGETTEXT=xgettext}
55 ${XGETTEXT} -o prog.tmp --omit-header --no-location -k_ prog.c || exit 1
56 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
60 msgid "'Your command, please?', asked the waiter."
64 msgid "a piece of cake"
65 msgid_plural "%d pieces of cake"
70 msgid "%s is replaced by %s."
75 ${DIFF} prog.ok prog.pot || exit 1
80 "Content-Type: text/plain; charset=ISO-8859-1\n"
81 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
84 msgid "'Your command, please?', asked the waiter."
85 msgstr "«Votre commande, s'il vous plait», dit le garçon."
87 # Les gateaux allemands sont les meilleurs du monde.
89 msgid "a piece of cake"
90 msgid_plural "%d pieces of cake"
91 msgstr[0] "un morceau de gateau"
92 msgstr[1] "%d morceaux de gateau"
94 # Reverse the arguments.
96 msgid "%s is replaced by %s."
97 msgstr "%2$s remplace %1$s."
100 : ${MSGMERGE=msgmerge}
101 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
102 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
105 ${DIFF} fr.po fr.po.new || exit 1
107 test -d fr || mkdir fr
108 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
111 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
115 «Votre commande, s'il vous plait», dit le garçon.
119 cat <<\EOF > prog.oku
120 «Votre commande, s'il vous plait», dit le garçon.
126 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
127 if test $LOCALE_FR != none; then
128 prepare_locale_ fr $LOCALE_FR
129 LANGUAGE= ./prog $LOCALE_FR 2 > prog.out
131 0) ${DIFF} prog.ok prog.out || exit 1;;
136 if test $LOCALE_FR_UTF8 != none; then
137 prepare_locale_ fr $LOCALE_FR_UTF8
138 LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out
140 0) ${DIFF} prog.oku prog.out || exit 1;;
141 77) LOCALE_FR_UTF8=none;;
145 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
146 if test -f /usr/bin/localedef; then
147 echo "Skipping test: no french locale is installed"
149 echo "Skipping test: no french locale is supported"