3 # Test of gettext facilities in the C language.
4 # Assumes an fr_FR locale is installed.
5 # Assumes the following packages are installed: gcc.
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles="$tmpfiles prog.c"
18 #define _(string) gettext (string)
20 int main (int argc, char *argv[])
22 int n = atoi (argv[2]);
24 xsetenv ("LC_ALL", argv[1], 1);
25 if (setlocale (LC_ALL, "") == NULL)
26 /* Couldn't set locale. */
30 bindtextdomain ("prog", ".");
32 printf (_("'Your command, please?', asked the waiter."));
35 printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);
38 printf (_("%s is replaced by %s."), "FF", "EUR");
45 # Variable needed by LTLIBINTL.
48 tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
49 # Put the -I flags before ${CFLAGS} ${CPPFLAGS}, to make sure that libintl.h
50 # is found in the build directory, regardless of -I options present in
51 # ${CFLAGS} or ${CPPFLAGS}.
52 ${LIBTOOL} --quiet --mode=link ${CC} -I.. -I$top_srcdir/gnulib-lib ../gnulib-lib/libgettextlib.la -I../intl ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.c ${LTLIBINTL} \
55 tmpfiles="$tmpfiles prog.tmp prog.pot"
56 : ${XGETTEXT=xgettext}
57 ${XGETTEXT} -o prog.tmp --omit-header --no-location -k_ prog.c
58 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
59 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot
60 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
62 tmpfiles="$tmpfiles prog.ok"
65 msgid "'Your command, please?', asked the waiter."
69 msgid "a piece of cake"
70 msgid_plural "%d pieces of cake"
75 msgid "%s is replaced by %s."
80 ${DIFF} prog.ok prog.pot || exit 1
82 tmpfiles="$tmpfiles fr.po"
86 "Content-Type: text/plain; charset=ISO-8859-1\n"
87 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
90 msgid "'Your command, please?', asked the waiter."
91 msgstr "«Votre commande, s'il vous plait», dit le garçon."
93 # Les gateaux allemands sont les meilleurs du monde.
95 msgid "a piece of cake"
96 msgid_plural "%d pieces of cake"
97 msgstr[0] "un morceau de gateau"
98 msgstr[1] "%d morceaux de gateau"
100 # Reverse the arguments.
102 msgid "%s is replaced by %s."
103 msgstr "%2$s remplace %1$s."
106 tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
107 : ${MSGMERGE=msgmerge}
108 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
109 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
110 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new
111 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
114 ${DIFF} fr.po fr.po.new || exit 1
116 tmpfiles="$tmpfiles fr"
117 test -d fr || mkdir fr
118 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
121 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
123 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
126 «Votre commande, s'il vous plait», dit le garçon.
130 cat <<\EOF > prog.oku
131 «Votre commande, s'il vous plait», dit le garçon.
137 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
138 if test $LOCALE_FR != none; then
139 LANGUAGE= ./prog $LOCALE_FR 2 > prog.out
141 0) ${DIFF} prog.ok prog.out || exit 1;;
146 if test $LOCALE_FR_UTF8 != none; then
147 LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out
149 0) ${DIFF} prog.oku prog.out || exit 1;;
150 77) LOCALE_FR_UTF8=none;;
154 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
155 if test -f /usr/bin/localedef; then
156 echo "Skipping test: no french locale is installed"
158 echo "Skipping test: no french locale is supported"
160 rm -fr $tmpfiles; exit 77