2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of gettext facilities in the Perl language,
5 # using printf format strings.
6 # Assumes an fr_FR locale is installed.
7 # Assumes the following packages are installed: perl.
9 cat <<\EOF > program1.pl
12 use Locale::Messages qw (textdomain bindtextdomain gettext ngettext);
14 bindtextdomain "prog", "./";
16 print gettext "'Your command, please?', asked the waiter.";
18 printf ngettext ("a piece of cake", "%d pieces of cake", $n), $n;
20 printf gettext "%s is replaced by %s.", "FF", "EUR";
24 : ${XGETTEXT=xgettext}
26 -k__ --flag=__:1:pass-perl-format --flag=__:1:pass-perl-brace-format \
27 -o prog.tmp --omit-header --no-location program1.pl || exit 1
28 LC_ALL=C tr -d '\r' < prog.tmp > prog.pot || exit 1
31 msgid "'Your command, please?', asked the waiter."
35 msgid "a piece of cake"
36 msgid_plural "%d pieces of cake"
41 msgid "%s is replaced by %s."
46 ${DIFF} prog.ok prog.pot || exit 1
51 "Content-Type: text/plain; charset=ISO-8859-1\n"
52 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
54 msgid "'Your command, please?', asked the waiter."
55 msgstr "«Votre commande, s'il vous plait», dit le garçon."
57 # Les gateaux allemands sont les meilleurs du monde.
59 msgid "a piece of cake"
60 msgid_plural "%d pieces of cake"
61 msgstr[0] "un morceau de gateau"
62 msgstr[1] "%d morceaux de gateau"
64 # Reverse the arguments.
66 msgid "%s is replaced by %s."
67 msgstr "%2$s remplace %1$s."
70 : ${MSGMERGE=msgmerge}
71 ${MSGMERGE} -q -o fr.po.tmp fr.po prog.pot || exit 1
72 LC_ALL=C tr -d '\r' < fr.po.tmp > fr.po.new || exit 1
75 ${DIFF} fr.po fr.po.new || exit 1
77 test -d fr || mkdir fr
78 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
81 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
85 «Votre commande, s'il vous plait», dit le garçon.
90 «Votre commande, s'il vous plait», dit le garçon.
95 # Test for perl with Locale::Messages package.
96 perl -e 'use Locale::Messages;' 2>/dev/null \
97 || { echo "Skipping test: perl package Locale::Messages is not installed"
102 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
103 if test $LOCALE_FR != none; then
104 prepare_locale_ fr $LOCALE_FR
105 LANGUAGE= LANG=$LOCALE_FR LC_MESSAGES= LC_CTYPE= LC_ALL= perl program1.pl > prog.out || exit 1
106 ${DIFF} prog.ok prog.out || exit 1
108 if test $LOCALE_FR_UTF8 != none; then
109 prepare_locale_ fr $LOCALE_FR_UTF8
110 LANGUAGE= LANG=$LOCALE_FR_UTF8 LC_MESSAGES= LC_CTYPE= LC_ALL= perl program1.pl > prog.out || exit 1
111 ${DIFF} prog.oku prog.out || exit 1
113 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
114 if test -f /usr/bin/localedef; then
115 echo "Skipping test: no french locale is installed"
117 echo "Skipping test: no french locale is supported"