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++.
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"
18 /* Avoid deprecation warnings from g
++ 3.1 or newer.
*/
19 #if defined __GNUG__ && defined __DEPRECATED
23 # include <iostream.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;
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)
54 cout << autosprintf (_("%s is replaced by %s."), "FF", "EUR") << endl;
58 # Variable needed by LTLIBINTL.
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 \
66 ${LIBTOOL} --quiet --mode=link ${CXX} ${CXXFLAGS} ${LDFLAGS} -o prog prog.${OBJEXT} ../../gettext-runtime/libasprintf/libasprintf.la ../lib/libgettextlib.la ${LTLIBINTL} \
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"
75 msgid "'Your command, please?', asked the waiter."
79 msgid "a piece of cake"
80 msgid_plural "%d pieces of cake"
85 msgid "%s is replaced by %s."
90 ${DIFF} prog.ok prog.pot || exit 1
92 tmpfiles="$tmpfiles fr.po"
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.
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.
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
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
127 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
129 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
132 «Votre commande, s'il vous plait», dit le garçon.
136 cat <<\EOF > prog.oku
137 «Votre commande, s'il vous plait», dit le garçon.
143 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
144 if test $LOCALE_FR != none; then
145 LANGUAGE= ./prog $LOCALE_FR 2 > prog.out
147 0) ${DIFF} prog.ok prog.out || exit 1;;
152 if test $LOCALE_FR_UTF8 != none; then
153 LANGUAGE= ./prog $LOCALE_FR_UTF8 2 > prog.out
155 0) ${DIFF} prog.oku prog.out || exit 1;;
156 77) LOCALE_FR_UTF8=none;;
160 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
161 rm -fr $tmpfiles; exit 77