3 # Test of gettext facilities in the Objective 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 # Test whether an ObjectiveC compiler is found.
11 tmpfiles="$tmpfiles hello.m hello.${OBJEXT} hello${EXEEXT}"
17 printf ("Hello world\n");
21 ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o hello hello.m 2>/dev/null \
22 || { echo "Skipping test: Objective C compiler not found"
23 rm -fr $tmpfiles; exit 77
26 tmpfiles="$tmpfiles prog.m"
34 #define _(string) gettext (string)
36 int main (int argc, char *argv[])
38 int n = atoi (argv[2]);
40 xsetenv ("LC_ALL", argv[1], 1);
41 if (setlocale (LC_ALL, "") == NULL)
42 /* Couldn't set locale. */
46 bindtextdomain ("prog", ".");
48 printf (_("'Your command, please?', asked the waiter."));
51 printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);
54 printf (_("%s is replaced by %s."), "FF", "EUR");
61 # Variable needed by LTLIBINTL.
64 tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
65 # Put the -I flags before ${CFLAGS} ${CPPFLAGS}, to make sure that libintl.h
66 # is found in the build directory, regardless of -I options present in
67 # ${CFLAGS} or ${CPPFLAGS}.
68 ${LIBTOOL} --quiet --mode=link ${CC} -I.. -I$top_srcdir/gnulib-lib ../gnulib-lib/libgettextlib.la -I../intl ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.m ${LTLIBINTL} \
71 tmpfiles="$tmpfiles prog.tmp prog.pot"
72 : ${XGETTEXT=xgettext}
73 ${XGETTEXT} -o prog.tmp --omit-header --no-location -k_ prog.m
74 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
75 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot
76 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
78 tmpfiles="$tmpfiles prog.ok"
81 msgid "'Your command, please?', asked the waiter."
85 msgid "a piece of cake"
86 msgid_plural "%d pieces of cake"
91 msgid "%s is replaced by %s."
96 ${DIFF} prog.ok prog.pot || exit 1
98 tmpfiles="$tmpfiles fr.po"
102 "Content-Type: text/plain; charset=ISO-8859-1\n"
103 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
106 msgid "'Your command, please?', asked the waiter."
107 msgstr "«Votre commande, s'il vous plait», dit le garçon."
109 # Les gateaux allemands sont les meilleurs du monde.
111 msgid "a piece of cake"
112 msgid_plural "%d pieces of cake"
113 msgstr[0] "un morceau de gateau"
114 msgstr[1] "%d morceaux de gateau"
116 # Reverse the arguments.
118 msgid "%s is replaced by %s."
119 msgstr "%2$s remplace %1$s."
122 tmpfiles="$tmpfiles fr.po.tmp fr.po.new"
123 : ${MSGMERGE=msgmerge}
124 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot
125 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
126 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new
127 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
130 ${DIFF} fr.po fr.po.new || exit 1
132 tmpfiles="$tmpfiles fr"
133 test -d fr || mkdir fr
134 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
137 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
139 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
142 «Votre commande, s'il vous plait», dit le garçon.
146 cat <<\EOF > prog.oku
147 «Votre commande, s'il vous plait», dit le garçon.
153 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
154 if test $LOCALE_FR != none; then
155 LANGUAGE= ./prog $LOCALE_FR 2 > prog.out
157 0) ${DIFF} prog.ok prog.out || exit 1;;
162 if test $LOCALE_FR_UTF8 != none; then
163 LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out
165 0) ${DIFF} prog.oku prog.out || exit 1;;
166 77) LOCALE_FR_UTF8=none;;
170 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
171 if test -f /usr/bin/localedef; then
172 echo "Skipping test: no french locale is installed"
174 echo "Skipping test: no french locale is supported"
176 rm -fr $tmpfiles; exit 77