Recently I asked a question in SoPW, but as I got no answer, I had to write it myself. The following code uses Plural-Forms header from .po file to add plural method to Locale::Maketext based class. This plural method may be used as a replacement for quant method.

package My::I18N; use strict; use warnings; use base 'Locale::Maketext'; use Locale::Maketext::Lexicon { '*' => [Gettext => 'i18n/*.po', }; =head2 plural($num, @strings) This method handles plural forms. You can invoke it using Locale::Maketext's bracket notation, like "[plural,_1,string1,string2,...]". Depending on value of I<$num> and language function returns one of the strings. If string contain %d it will be replaced with I<$num> value. =cut sub plural { my ($self, $num, @strings) = @_; unless ($self->{_plural}) { my $class = ref $self; no strict 'refs'; my $header = ${"${class}::Lexicon"}{"__Plural-Forms"}; if ($header) { $header =~ s/^.*plural\s*=\s*([^;]+);.*$/$1/; $header =~ s/\[_([0-9]+)\]/%$1/g; die "Invalid expression for plural: $header" if $header =~ + /\$|n\s*\(|[A-Za-mo-z]|nn/; $header =~ s/n/\$_[0]/g; eval "\$self->{_plural} = sub { return $header }"; } else { $self->{_plural} = sub { return $_[0] != 1 }; } } return sprintf $strings[$self->{_plural}($num)], $num; }

In reply to Plural forms support in Locale::Maketext::Lexicon by zwon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.