#!/bin/sh # Test of Perl support. tmpfiles="" trap 'rm -fr $tmpfiles' 1 2 3 15 tmpfiles="$tmpfiles xg-pl-1.pl" cat <<\EOF > xg-pl-1.pl use Locale::Messages qw (textdomain bindtextdomain gettext ngettext dngettext); textdomain "prog"; bindtextdomain "prog", "./"; s/foo/ # stress test for string extraction /xe; print _"'Your command, please?', asked the waiter."; printf ngettext ("a piece of cake", "%d pieces of cake", $n), $n; printf _"%s is replaced by %s.", "FF", "EUR"; # Should be found. printf dngettext prog => ("one file deleted", "%d files deleted"), $n, $n; # Should not be found. printf dngettext ("prog"), ("one file created", "%d files created"), $n, $n; printf dngettext "prog", <{"quoted string"} tied hash $__->{ "weird formatting"} PERL print $__ # Welcome -> # to the { # Republic of 'Welcome to the Republic of Perl!' # # Perl! }; $! ? ?$__{"pattern match"}? : s # This is no delimiter. {$__{substitution}}<$__-\>{"find me"}>; # No interpolation! m'$__{secret}'; # Multiple here documents invoked from the same line. print gettext < xg-pl-1.po test $? = 0 || { rm -fr $tmpfiles; exit 1; } tmpfiles="$tmpfiles xg-pl-1.ok" cat <<\EOF > xg-pl-1.ok #: xg-pl-1.pl:9 msgid "'Your command, please?', asked the waiter." msgstr "" #: xg-pl-1.pl:11 #, perl-format msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "" msgstr[1] "" #: xg-pl-1.pl:13 #, perl-format msgid "%s is replaced by %s." msgstr "" #: xg-pl-1.pl:16 #, perl-format msgid "one file deleted" msgid_plural "%d files deleted" msgstr[0] "" msgstr[1] "" #: xg-pl-1.pl:22 #, perl-format msgid "Singular\n" msgid_plural "Plural\n" msgstr[0] "" msgstr[1] "" #: xg-pl-1.pl:28 msgid "Bareword" msgstr "" #: xg-pl-1.pl:30 msgid "quoted string" msgstr "" #: xg-pl-1.pl:31 msgid "" "weird\n" "formatting" msgstr "" #: xg-pl-1.pl:38 msgid "Welcome to the Republic of Perl!" msgstr "" #: xg-pl-1.pl:42 msgid "pattern match" msgstr "" #: xg-pl-1.pl:43 msgid "substitution" msgstr "" #: xg-pl-1.pl:43 msgid "find me" msgstr "" #: xg-pl-1.pl:50 msgid "First here document.\n" msgstr "" #: xg-pl-1.pl:52 msgid "Second here document.\n" msgstr "" #: xg-pl-1.pl:56 msgid "abc$def" msgstr "" #: xg-pl-1.pl:57 msgid "abc\\$def" msgstr "" #: xg-pl-1.pl:60 msgid "abc$defg" msgstr "" #: xg-pl-1.pl:61 xg-pl-1.pl:62 msgid "abc\\$defg" msgstr "" #: xg-pl-1.pl:63 msgid "abc\\\\$defg" msgstr "" #: xg-pl-1.pl:66 xg-pl-1.pl:67 xg-pl-1.pl:71 xg-pl-1.pl:72 xg-pl-1.pl:81 #: xg-pl-1.pl:86 msgid "ecs\\tasy" msgstr "" #: xg-pl-1.pl:68 xg-pl-1.pl:69 xg-pl-1.pl:73 xg-pl-1.pl:74 xg-pl-1.pl:83 #: xg-pl-1.pl:88 msgid "ecs\\\\tasy" msgstr "" #: xg-pl-1.pl:70 xg-pl-1.pl:75 msgid "ecs\\\\\\tasy" msgstr "" #: xg-pl-1.pl:80 xg-pl-1.pl:85 msgid "ecs\tasy" msgstr "" #: xg-pl-1.pl:82 xg-pl-1.pl:87 msgid "ecs\\\tasy" msgstr "" #: xg-pl-1.pl:84 xg-pl-1.pl:89 msgid "ecs\\\\\tasy" msgstr "" #: xg-pl-1.pl:90 xg-pl-1.pl:95 msgid "marihuana" msgstr "" #: xg-pl-1.pl:91 xg-pl-1.pl:92 xg-pl-1.pl:96 xg-pl-1.pl:97 msgid "mari\\huana" msgstr "" #: xg-pl-1.pl:93 xg-pl-1.pl:94 xg-pl-1.pl:98 xg-pl-1.pl:99 msgid "mari\\\\huana" msgstr "" #: xg-pl-1.pl:102 #, perl-brace-format msgid "This is {only} a brace formatstring." msgstr "" #: xg-pl-1.pl:103 #, perl-format, perl-brace-format msgid "This is %s {mixed}." msgstr "" #: xg-pl-1.pl:104 #, perl-format msgid "This is only %c." msgstr "" #: xg-pl-1.pl:105 msgid "This is nothing at all." msgstr "" #: xg-pl-1.pl:106 msgid "And this is %l also no format at all." msgstr "" #: xg-pl-1.pl:109 #, no-perl-format, perl-brace-format msgid "The function '{func}' expects '%c' here." msgstr "" #: xg-pl-1.pl:114 xg-pl-1.pl:116 xg-pl-1.pl:118 #, perl-format, no-perl-brace-format msgid "Left as an %exercise to {maintainer}." msgstr "" #: xg-pl-1.pl:138 msgid "Before slash-slash" msgstr "" #: xg-pl-1.pl:140 msgid "After slash-slash" msgstr "" EOF : ${DIFF=diff} ${DIFF} xg-pl-1.ok xg-pl-1.po result=$? rm -fr $tmpfiles exit $result