No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-perl-1
blobccd2d85ffcb832457d4417d08fdaae0405c43d2d
1 #! /bin/sh
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.
8 tmpfiles=""
9 trap 'rm -fr $tmpfiles' 1 2 3 15
11 tmpfiles="$tmpfiles program.pl"
12 cat <<\EOF > program.pl
13 use strict;
15 use Locale::Messages qw (textdomain bindtextdomain gettext ngettext);
16 textdomain "prog";
17 bindtextdomain "prog", "./";
18 my $n = 2;
19 print gettext "'Your command, please?', asked the waiter.";
20 print "\n";
21 printf ngettext ("a piece of cake", "%d pieces of cake", $n), $n;
22 print "\n";
23 printf gettext "%s is replaced by %s.", "FF", "EUR";
24 print "\n";
25 EOF
27 tmpfiles="$tmpfiles prog.pot"
28 : ${XGETTEXT=xgettext}
29 ${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"
34 cat <<EOF > prog.ok
35 msgid "'Your command, please?', asked the waiter."
36 msgstr ""
38 #, perl-format
39 msgid "a piece of cake"
40 msgid_plural "%d pieces of cake"
41 msgstr[0] ""
42 msgstr[1] ""
44 #, perl-format
45 msgid "%s is replaced by %s."
46 msgstr ""
47 EOF
49 : ${DIFF=diff}
50 ${DIFF} prog.ok prog.pot || exit 1
52 tmpfiles="$tmpfiles fr.po"
53 cat <<\EOF > fr.po
54 msgid ""
55 msgstr ""
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.
63 #, perl-format
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.
70 #, perl-format
71 msgid "%s is replaced by %s."
72 msgstr "%2$s remplace %1$s."
73 EOF
75 tmpfiles="$tmpfiles fr.po.new"
76 : ${MSGMERGE=msgmerge}
77 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
79 : ${DIFF=diff}
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
86 : ${MSGFMT=msgfmt}
87 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
89 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
90 : ${DIFF=diff}
91 cat <<\EOF > prog.ok
92 «Votre commande, s'il vous plait», dit le garçon.
93 2 morceaux de gateau
94 EUR remplace FF.
95 EOF
96 cat <<\EOF > prog.oku
97 «Votre commande, s'il vous plait», dit le garçon.
98 2 morceaux de gateau
99 EUR remplace FF.
102 # Test for perl with Locale::Messages package.
103 perl -e 'use Locale::Messages;' 2>/dev/null \
104 || { rm -fr $tmpfiles; exit 77; }
106 : ${LOCALE_FR=fr_FR}
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
120 rm -fr $tmpfiles
122 exit 0