3 # Test of gettext facilities in the Perl language,
4 # using printf format strings.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: perl.
9 trap 'rm -fr $tmpfiles' 1 2 3 15
11 tmpfiles
="$tmpfiles program.pl"
12 cat <<\EOF
> program.pl
15 use Locale
::Messages qw
(textdomain bindtextdomain
gettext ngettext
);
17 bindtextdomain
"prog", "./";
19 print
gettext "'Your command, please?', asked the waiter.";
21 printf ngettext
("a piece of cake", "%d pieces of cake", $n), $n;
23 printf gettext "%s is replaced by %s.", "FF", "EUR";
27 tmpfiles
="$tmpfiles prog.pot"
28 : ${XGETTEXT=xgettext}
30 -k__ --flag=__
:1:pass-perl-format
--flag=__
:1:pass-perl-brace-format \
31 -o prog.pot
--omit-header --no-location program.pl
33 tmpfiles
="$tmpfiles prog.ok"
35 msgid "'Your command, please?', asked the waiter."
39 msgid "a piece of cake"
40 msgid_plural "%d pieces of cake"
45 msgid "%s is replaced by %s."
50 ${DIFF} prog.ok prog.pot ||
exit 1
52 tmpfiles
="$tmpfiles fr.po"
56 "Content-Type: text/plain; charset=ISO-8859-1\n"
57 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
59 msgid
"'Your command, please?', asked the waiter."
60 msgstr
"«Votre commande, s'il vous plait», dit le garçon."
62 # Les gateaux allemands sont les meilleurs du monde.
64 msgid
"a piece of cake"
65 msgid_plural
"%d pieces of cake"
66 msgstr
[0] "un morceau de gateau"
67 msgstr
[1] "%d morceaux de gateau"
69 # Reverse the arguments.
71 msgid
"%s is replaced by %s."
72 msgstr
"%2$s remplace %1$s."
75 tmpfiles
="$tmpfiles fr.po.new"
76 : ${MSGMERGE=msgmerge}
77 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
80 ${DIFF} fr.po fr.po.new ||
exit 1
82 tmpfiles
="$tmpfiles fr"
83 test -d fr || mkdir fr
84 test -d fr
/LC_MESSAGES || mkdir fr
/LC_MESSAGES
87 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
89 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
92 «Votre commande
, s
'il vous plait», dit le garçon.
97 «Votre commande, s'il vous plait»
, dit le garçon.
102 # Test for perl with Locale::Messages package.
103 perl
-e 'use Locale::Messages;' 2>/dev
/null \
104 ||
{ rm -fr $tmpfiles; exit 77; }
107 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
108 if test $LOCALE_FR != none
; then
109 LANGUAGE
= LANG
=$LOCALE_FR LC_MESSAGES
= LC_CTYPE
= LC_ALL
= perl program.pl
> prog.out ||
exit 1
110 ${DIFF} prog.ok prog.out ||
exit 1
112 if test $LOCALE_FR_UTF8 != none
; then
113 LANGUAGE
= LANG
=$LOCALE_FR_UTF8 LC_MESSAGES
= LC_CTYPE
= LC_ALL
= perl program.pl
> prog.out ||
exit 1
114 ${DIFF} prog.oku prog.out ||
exit 1
116 if test $LOCALE_FR = none
&& test $LOCALE_FR_UTF8 = none
; then
117 rm -fr $tmpfiles; exit 77