No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-objc
blob53f7ae69043b98cdd1871cca21b605296890de1c
1 #! /bin/sh
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.
7 tmpfiles=""
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}"
12 cat <<\EOF > hello.m
13 #include <stdio.h>
14 #include <stdlib.h>
15 int main ()
17 printf ("Hello world\n");
18 exit (0);
20 EOF
21 ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o hello hello.m 2>/dev/null \
22 || { rm -fr $tmpfiles; exit 77; }
24 tmpfiles="$tmpfiles prog.m"
25 cat <<\EOF > prog.m
26 #include "config.h"
27 #include <libintl.h>
28 #include <locale.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include "xsetenv.h"
32 #define _(string) gettext (string)
34 int main (int argc, char *argv[])
36 int n = atoi (argv[2]);
38 xsetenv ("LC_ALL", argv[1], 1);
39 if (setlocale (LC_ALL, "") == NULL)
41 fprintf (stderr, "Couldn't set locale.\n");
42 exit (77);
45 textdomain ("prog");
46 bindtextdomain ("prog", ".");
48 printf (_("'Your command, please?', asked the waiter."));
49 printf ("\n");
51 printf (ngettext ("a piece of cake", "%d pieces of cake", n), n);
52 printf ("\n");
54 printf (_("%s is replaced by %s."), "FF", "EUR");
55 printf ("\n");
57 exit (0);
59 EOF
61 # Variable needed by LTLIBINTL.
62 top_builddir=..
64 tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
65 ${LIBTOOL} --quiet --mode=link ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -o prog prog.m -I.. -I$top_srcdir/lib ../lib/libgettextlib.la -I../intl ${LTLIBINTL} \
66 || exit 1
68 tmpfiles="$tmpfiles prog.pot"
69 : ${XGETTEXT=xgettext}
70 ${XGETTEXT} -o prog.pot --omit-header --no-location -k_ prog.m
72 tmpfiles="$tmpfiles prog.ok"
73 cat <<EOF > prog.ok
74 #, c-format
75 msgid "'Your command, please?', asked the waiter."
76 msgstr ""
78 #, c-format
79 msgid "a piece of cake"
80 msgid_plural "%d pieces of cake"
81 msgstr[0] ""
82 msgstr[1] ""
84 #, c-format
85 msgid "%s is replaced by %s."
86 msgstr ""
87 EOF
89 : ${DIFF=diff}
90 ${DIFF} prog.ok prog.pot || exit 1
92 tmpfiles="$tmpfiles fr.po"
93 cat <<\EOF > fr.po
94 msgid ""
95 msgstr ""
96 "Content-Type: text/plain; charset=ISO-8859-1\n"
97 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
99 #, c-format
100 msgid "'Your command, please?', asked the waiter."
101 msgstr "«Votre commande, s'il vous plait», dit le garçon."
103 # Les gateaux allemands sont les meilleurs du monde.
104 #, c-format
105 msgid "a piece of cake"
106 msgid_plural "%d pieces of cake"
107 msgstr[0] "un morceau de gateau"
108 msgstr[1] "%d morceaux de gateau"
110 # Reverse the arguments.
111 #, c-format
112 msgid "%s is replaced by %s."
113 msgstr "%2$s remplace %1$s."
116 tmpfiles="$tmpfiles fr.po.new"
117 : ${MSGMERGE=msgmerge}
118 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
120 : ${DIFF=diff}
121 ${DIFF} fr.po fr.po.new || exit 1
123 tmpfiles="$tmpfiles fr"
124 test -d fr || mkdir fr
125 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
127 : ${MSGFMT=msgfmt}
128 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
130 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
131 : ${DIFF=diff}
132 cat <<\EOF > prog.ok
133 «Votre commande, s'il vous plait», dit le garçon.
134 2 morceaux de gateau
135 EUR remplace FF.
137 cat <<\EOF > prog.oku
138 «Votre commande, s'il vous plait», dit le garçon.
139 2 morceaux de gateau
140 EUR remplace FF.
143 : ${LOCALE_FR=fr_FR}
144 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
145 if test $LOCALE_FR != none; then
146 LANGUAGE= ./prog $LOCALE_FR 2 > prog.out
147 case $? in
148 0) ${DIFF} prog.ok prog.out || exit 1;;
149 77) LOCALE_FR=none;;
150 *) exit 1;;
151 esac
153 if test $LOCALE_FR_UTF8 != none; then
154 LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out
155 case $? in
156 0) ${DIFF} prog.oku prog.out || exit 1;;
157 77) LOCALE_FR_UTF8=none;;
158 *) exit 1;;
159 esac
161 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
162 rm -fr $tmpfiles; exit 77
165 rm -fr $tmpfiles
167 exit 0