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.
8 trap 'rm -fr $tmpfiles' 1 2 3 15
10 tmpfiles
="$tmpfiles prog.c"
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");
32 bindtextdomain
("prog", ".");
34 printf (_
("'Your command, please?', asked the waiter."));
37 printf (ngettext
("a piece of cake", "%d pieces of cake", n
), n
);
40 printf (_
("%s is replaced by %s."), "FF", "EUR");
47 # Variable needed by LTLIBINTL.
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} \
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"
61 msgid "'Your command, please?', asked the waiter."
65 msgid "a piece of cake"
66 msgid_plural "%d pieces of cake"
71 msgid "%s is replaced by %s."
76 ${DIFF} prog.ok prog.pot ||
exit 1
78 tmpfiles
="$tmpfiles fr.po"
82 "Content-Type: text/plain; charset=ISO-8859-1\n"
83 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
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.
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.
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
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
114 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
116 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
119 «Votre commande
, s
'il vous plait», dit le garçon.
123 cat <<\EOF > prog.oku
124 «Votre commande, s'il vous plait»
, dit le garçon.
130 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
131 if test $LOCALE_FR != none
; then
132 LANGUAGE
= .
/prog
$LOCALE_FR 2 > prog.out
134 0) ${DIFF} prog.ok prog.out ||
exit 1;;
139 if test $LOCALE_FR_UTF8 != none
; then
140 LANGUAGE
= .
/prog
$LOCALE_FR_UTF8 2 > prog.out
142 0) ${DIFF} prog.oku prog.out ||
exit 1;;
143 77) LOCALE_FR_UTF8
=none
;;
147 if test $LOCALE_FR = none
&& test $LOCALE_FR_UTF8 = none
; then
148 rm -fr $tmpfiles; exit 77