No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-c
blob21f1907efb672cccc549a8439935d888133a375b
1 #! /bin/sh
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.
7 tmpfiles=""
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles="$tmpfiles prog.c"
11 cat <<\EOF > prog.c
12 #include "config.h"
13 #include <libintl.h>
14 #include <locale.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include "xsetenv.h"
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)
27 fprintf (stderr, "Couldn't set locale.\n");
28 exit (77);
31 textdomain ("prog");
32 bindtextdomain ("prog", ".");
34 printf (_("'Your command, please?', asked the waiter."));
35 printf ("\n");
37 printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);
38 printf ("\n");
40 printf (_("%s is replaced by %s."), "FF", "EUR");
41 printf ("\n");
43 exit (0);
45 EOF
47 # Variable needed by LTLIBINTL.
48 top_builddir=..
50 tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
51 ${LIBTOOL} --quiet --mode=link ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.c -I.. -I$top_srcdir/lib ../lib/libgettextlib.la -I../intl ${LTLIBINTL} \
52 || exit 1
54 tmpfiles="$tmpfiles prog.pot"
55 : ${XGETTEXT=xgettext}
56 ${XGETTEXT} -o prog.pot --omit-header --no-location -k_ prog.c
58 tmpfiles="$tmpfiles prog.ok"
59 cat <<EOF > prog.ok
60 #, c-format
61 msgid "'Your command, please?', asked the waiter."
62 msgstr ""
64 #, c-format
65 msgid "a piece of cake"
66 msgid_plural "%d pieces of cake"
67 msgstr[0] ""
68 msgstr[1] ""
70 #, c-format
71 msgid "%s is replaced by %s."
72 msgstr ""
73 EOF
75 : ${DIFF=diff}
76 ${DIFF} prog.ok prog.pot || exit 1
78 tmpfiles="$tmpfiles fr.po"
79 cat <<\EOF > fr.po
80 msgid ""
81 msgstr ""
82 "Content-Type: text/plain; charset=ISO-8859-1\n"
83 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
85 #, c-format
86 msgid "'Your command, please?', asked the waiter."
87 msgstr "«Votre commande, s'il vous plait», dit le garçon."
89 # Les gateaux allemands sont les meilleurs du monde.
90 #, c-format
91 msgid "a piece of cake"
92 msgid_plural "%d pieces of cake"
93 msgstr[0] "un morceau de gateau"
94 msgstr[1] "%d morceaux de gateau"
96 # Reverse the arguments.
97 #, c-format
98 msgid "%s is replaced by %s."
99 msgstr "%2$s remplace %1$s."
102 tmpfiles="$tmpfiles fr.po.new"
103 : ${MSGMERGE=msgmerge}
104 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
106 : ${DIFF=diff}
107 ${DIFF} fr.po fr.po.new || exit 1
109 tmpfiles="$tmpfiles fr"
110 test -d fr || mkdir fr
111 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
113 : ${MSGFMT=msgfmt}
114 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
116 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
117 : ${DIFF=diff}
118 cat <<\EOF > prog.ok
119 «Votre commande, s'il vous plait», dit le garçon.
120 2 morceaux de gateau
121 EUR remplace FF.
123 cat <<\EOF > prog.oku
124 «Votre commande, s'il vous plait», dit le garçon.
125 2 morceaux de gateau
126 EUR remplace FF.
129 : ${LOCALE_FR=fr_FR}
130 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
131 if test $LOCALE_FR != none; then
132 LANGUAGE= ./prog $LOCALE_FR 2 > prog.out
133 case $? in
134 0) ${DIFF} prog.ok prog.out || exit 1;;
135 77) LOCALE_FR=none;;
136 *) exit 1;;
137 esac
139 if test $LOCALE_FR_UTF8 != none; then
140 LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out
141 case $? in
142 0) ${DIFF} prog.oku prog.out || exit 1;;
143 77) LOCALE_FR_UTF8=none;;
144 *) exit 1;;
145 esac
147 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
148 rm -fr $tmpfiles; exit 77
151 rm -fr $tmpfiles
153 exit 0