No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / lang-perl-2
blob940aaeea5b34ead3d40ece4dd2c2de606d8ae862
1 #! /bin/sh
3 # Test of gettext facilities in the Perl language,
4 # using brace format strings.
5 # Assumes an fr_FR locale is installed.
6 # Assumes the following packages are installed: perl, libintl-perl.
8 tmpfiles=""
9 trap 'rm -fr $tmpfiles' 1 2 3 15
11 tmpfiles="$tmpfiles program.pl"
12 cat <<\EOF > program.pl
13 use Locale::TextDomain (prog => './');
14 my $n = 2;
15 print __"'Your command, please?', asked the waiter.";
16 print "\n";
17 printf __n ("a piece of cake", "%d pieces of cake", $n), $n;
18 print "\n";
19 printf __x ("{old} is replaced by {new}.", old => "FF", new => "EUR");
20 print "\n";
21 EOF
23 tmpfiles="$tmpfiles prog.pot"
24 : ${XGETTEXT=xgettext}
25 ${XGETTEXT} \
26 -k__ --flag=__:1:pass-perl-format --flag=__:1:pass-perl-brace-format \
27 -k__n:1,2 --flag=__n:1:pass-perl-format --flag=__n:1:pass-perl-brace-format \
28 --flag=__n:2:pass-perl-format --flag=__n:2:pass-perl-brace-format \
29 -k__x --flag=__x:1:perl-brace-format \
30 -o prog.pot --omit-header --no-location program.pl
32 tmpfiles="$tmpfiles prog.ok"
33 cat <<EOF > prog.ok
34 msgid "'Your command, please?', asked the waiter."
35 msgstr ""
37 #, perl-format
38 msgid "a piece of cake"
39 msgid_plural "%d pieces of cake"
40 msgstr[0] ""
41 msgstr[1] ""
43 #, perl-brace-format
44 msgid "{old} is replaced by {new}."
45 msgstr ""
46 EOF
48 : ${DIFF=diff}
49 ${DIFF} prog.ok prog.pot || exit 1
51 tmpfiles="$tmpfiles fr.po"
52 cat <<\EOF > fr.po
53 msgid ""
54 msgstr ""
55 "Content-Type: text/plain; charset=ISO-8859-1\n"
56 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
58 msgid "'Your command, please?', asked the waiter."
59 msgstr "«Votre commande, s'il vous plait», dit le garçon."
61 # Les gateaux allemands sont les meilleurs du monde.
62 #, perl-format
63 msgid "a piece of cake"
64 msgid_plural "%d pieces of cake"
65 msgstr[0] "un morceau de gateau"
66 msgstr[1] "%d morceaux de gateau"
68 # Reverse the arguments.
69 #, perl-brace-format
70 msgid "{old} is replaced by {new}."
71 msgstr "{new} remplace {old}."
72 EOF
74 tmpfiles="$tmpfiles fr.po.new"
75 : ${MSGMERGE=msgmerge}
76 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
78 : ${DIFF=diff}
79 ${DIFF} fr.po fr.po.new || exit 1
81 tmpfiles="$tmpfiles fr"
82 test -d fr || mkdir fr
83 test -d fr/LC_MESSAGES || mkdir fr/LC_MESSAGES
85 : ${MSGFMT=msgfmt}
86 ${MSGFMT} -o fr/LC_MESSAGES/prog.mo fr.po
88 tmpfiles="$tmpfiles prog.ok prog.oku prog.out"
89 : ${DIFF=diff}
90 cat <<\EOF > prog.ok
91 «Votre commande, s'il vous plait», dit le garçon.
92 2 morceaux de gateau
93 EUR remplace FF.
94 EOF
95 cat <<\EOF > prog.oku
96 «Votre commande, s'il vous plait», dit le garçon.
97 2 morceaux de gateau
98 EUR remplace FF.
99 EOF
101 # Test for perl with libintl-perl package.
102 perl -M'Locale::TextDomain' -e '' 2>/dev/null \
103 || { rm -fr $tmpfiles; exit 77; }
105 : ${LOCALE_FR=fr_FR}
106 : ${LOCALE_FR_UTF8=fr_FR.UTF-8}
107 if test $LOCALE_FR != none; then
108 LANGUAGE= LANG=$LOCALE_FR LC_MESSAGES= LC_CTYPE= LC_ALL= perl program.pl > prog.out || exit 1
109 ${DIFF} prog.ok prog.out || exit 1
111 if test $LOCALE_FR_UTF8 != none; then
112 LANGUAGE= LANG=$LOCALE_FR_UTF8 LC_MESSAGES= LC_CTYPE= LC_ALL= perl program.pl > prog.out || exit 1
113 ${DIFF} prog.oku prog.out || exit 1
115 if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
116 rm -fr $tmpfiles; exit 77
119 rm -fr $tmpfiles
121 exit 0