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.
9 trap 'rm -fr $tmpfiles' 1 2 3 15
11 tmpfiles
="$tmpfiles program.pl"
12 cat <<\EOF
> program.pl
13 use Locale
::TextDomain
(prog
=> './');
15 print __
"'Your command, please?', asked the waiter.";
17 printf __n
("a piece of cake", "%d pieces of cake", $n), $n;
19 printf __x
("{old} is replaced by {new}.", old
=> "FF", new
=> "EUR");
23 tmpfiles
="$tmpfiles prog.pot"
24 : ${XGETTEXT=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"
34 msgid "'Your command, please?', asked the waiter."
38 msgid "a piece of cake"
39 msgid_plural "%d pieces of cake"
44 msgid "{old} is replaced by {new}."
49 ${DIFF} prog.ok prog.pot ||
exit 1
51 tmpfiles
="$tmpfiles fr.po"
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.
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.
70 msgid
"{old} is replaced by {new}."
71 msgstr
"{new} remplace {old}."
74 tmpfiles
="$tmpfiles fr.po.new"
75 : ${MSGMERGE=msgmerge}
76 ${MSGMERGE} -q -o fr.po.new fr.po prog.pot
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
86 ${MSGFMT} -o fr
/LC_MESSAGES
/prog.mo fr.po
88 tmpfiles
="$tmpfiles prog.ok prog.oku prog.out"
91 «Votre commande
, s
'il vous plait», dit le garçon.
96 «Votre commande, s'il vous plait»
, dit le garçon.
101 # Test for perl with libintl-perl package.
102 perl
-M'Locale::TextDomain' -e '' 2>/dev
/null \
103 ||
{ rm -fr $tmpfiles; exit 77; }
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