No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-c++
blob59bb399e69841d7e2176e7e9d7fea45e7332c933
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 g++.
7 tmpfiles=""
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 # Test whether a C++ compiler is found and libasprintf is built.
11 test "${CXX}" != ":" || exit 77
12 test "${TESTLIBASPRINTF}" = yes || exit 77
14 tmpfiles="$tmpfiles prog.cc"
15 cat <<\EOF > prog.cc
16 #include "config.h"
18 /* Avoid deprecation warnings from g++ 3.1 or newer. */
19 #if defined __GNUG__ && defined __DEPRECATED
20 # include <iostream>
21 using namespace std;
22 #else
23 # include <iostream.h>
24 #endif
26 #include <libintl.h>
27 #include <locale.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include "xsetenv.h"
31 #include "autosprintf.h"
32 using gnu::autosprintf;
33 #define _(string) gettext (string)
35 int main (int argc, char *argv[])
37 int n = atoi (argv[2]);
39 xsetenv ("LC_ALL", argv[1], 1);
40 if (setlocale (LC_ALL, "") == NULL)
42 cerr << "Couldn't set locale." << endl;
43 exit (77);
46 textdomain ("prog");
47 bindtextdomain ("prog", ".");
49 cout << _("'Your command, please?', asked the waiter.") << endl;
51 cout << autosprintf (ngettext ("a piece of cake", "%d pieces of cake", n), n)
52 << endl;
54 cout << autosprintf (_("%s is replaced by %s."), "FF", "EUR") << endl;
56 EOF
58 # Variable needed by LTLIBINTL.
59 top_builddir=..
61 tmpfiles="$tmpfiles prog.${OBJEXT} prog${EXEEXT}"
62 # Compile in two steps from .cc to .o and from .o to 'prog'. This way,
63 # relinking is faster because doesn't need to redo the first step.
64 ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c prog.cc -I.. -I../../gettext-runtime/libasprintf -I$top_srcdir/lib -I../intl \
65 || exit 1
66 ${LIBTOOL} --quiet --mode=link ${CXX} ${CXXFLAGS} ${LDFLAGS} -o prog prog.${OBJEXT} ../../gettext-runtime/libasprintf/libasprintf.la ../lib/libgettextlib.la ${LTLIBINTL} \
67 || exit 1
69 tmpfiles="$tmpfiles prog.pot"
70 : ${XGETTEXT=xgettext}
71 ${XGETTEXT} -o prog.pot --omit-header --no-location -k_ prog.cc
73 tmpfiles="$tmpfiles prog.ok"
74 cat <<EOF > prog.ok
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 msgid "'Your command, please?', asked the waiter."
100 msgstr "«Votre commande, s'il vous plait», dit le garçon."
102 # Les gateaux allemands sont les meilleurs du monde.
103 #, c-format
104 msgid "a piece of cake"
105 msgid_plural "%d pieces of cake"
106 msgstr[0] "un morceau de gateau"
107 msgstr[1] "%d morceaux de gateau"
109 # Reverse the arguments.
110 #, c-format
111 msgid "%s is replaced by %s."
112 msgstr "%2$s remplace %1$s."
115 tmpfiles="$tmpfiles fr.po.new"
116 : ${MSGMERGE=msgmerge}
117 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
119 : ${DIFF=diff}
120 ${DIFF} fr.po fr.po.new || exit 1
122 tmpfiles="$tmpfiles fr"
123 test -d fr || mkdir fr
124 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
126 : ${MSGFMT=msgfmt}
127 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
129 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
130 : ${DIFF=diff}
131 cat <<\EOF > prog.ok
132 «Votre commande, s'il vous plait», dit le garçon.
133 2 morceaux de gateau
134 EUR remplace FF.
136 cat <<\EOF > prog.oku
137 «Votre commande, s'il vous plait», dit le garçon.
138 2 morceaux de gateau
139 EUR remplace FF.
142 : ${LOCALE_FR=fr_FR}
143 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
144 if test $LOCALE_FR != none; then
145 LANGUAGE= ./prog $LOCALE_FR 2 > prog.out
146 case $? in
147 0) ${DIFF} prog.ok prog.out || exit 1;;
148 77) LOCALE_FR=none;;
149 *) exit 1;;
150 esac
152 if test $LOCALE_FR_UTF8 != none; then
153 LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out
154 case $? in
155 0) ${DIFF} prog.oku prog.out || exit 1;;
156 77) LOCALE_FR_UTF8=none;;
157 *) exit 1;;
158 esac
160 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
161 rm -fr $tmpfiles; exit 77
164 rm -fr $tmpfiles
166 exit 0