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; }