Skip Menu |

This queue is for tickets about the Form-Processor CPAN distribution.

Report information
The Basics
Id: 78438
Status: rejected
Priority: 0/
Queue: Form-Processor

People
Owner: Nobody in particular
Requestors: PHRED [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.31
Fixed in: (no value)



We came across another text fragment that needs a localization fix for the plural context. lib/Form/Processor/Field/Text.pm 40: $field->add_error( 'Please limit to [quant,_1,character]. You submitted [_2]', $size, length $value ); 40: $field->add_error( 'Please limit to [quant,_1,character,characters]. You submitted [_2]', $size, length $value );
On Tue Jul 17 19:36:48 2012, PHRED wrote: Show quoted text
> We came across another text fragment that needs a localization fix for > the plural context. > > lib/Form/Processor/Field/Text.pm > 40: $field->add_error( 'Please limit to > [quant,_1,character]. You submitted [_2]', $size, > length $value ); > > > 40: $field->add_error( 'Please limit to > [quant,_1,character,characters]. You submitted > [_2]', $size, length $value );
Locale::Maketext handles that automatically. use Locale::MakeText; use strict; use warnings; use feature 'say'; my $pattern = 'limit to [quant,_1,character]'; { package MyI18N; our @ISA = ('Locale::Maketext'); } { package MyI18N::en; our @ISA = ('MyI18N'); our %Lexicon = ( $pattern => $pattern, ); } my $lh = MyI18N->get_handle('en'); say $lh->maketext( $pattern, 1 ); say $lh->maketext( $pattern, 2 ); Results in: limit to 1 character limit to 2 characters
I found two more instances of quant calls that needed the plural message added. Currently we cannot completely translate these error messages for when the plural case is executed. --- lib/Form/Processor/Field.pm 2012-07-11 21:43:14.000000000 -0700 +++ Field.pm 2012-07-18 13:57:19.062574455 -0700 @@ -461,7 +461,7 @@ my $value = $field->input; if ( length( $value ) > $size ) { - $field->add_error( 'Please limit to [quant,_1,character]. You submitted [_2]', $size, length $value ); + $field->add_error( 'Please limit to [quant,_1,character,characters]. You submitted [_2]', $size, length $value ); return; } } --- lib/Form/Processor/Field/Text.pm 2011-05-19 07:54:23.000000000 -0700 +++ Text.pm 2012-07-18 13:56:50.944099709 -0700 @@ -31,7 +31,7 @@ my $value = $field->input; - return $field->add_error( 'Please limit to [quant,_1,character]. You submitted [_2]', $size, length $value ) + return $field->add_error( 'Please limit to [quant,_1,character,characters]. You submitted [_2]', $size, length $value ) if length $value > $size; } @@ -39,7 +39,7 @@ # Check for min length if ( my $size = $field->min_length ) { - return $field->add_error( 'Input must be at least [quant,_1,character]. You submitted [_2]', $size, length $value ) + return $field->add_error( 'Input must be at least [quant,_1,character,characters]. You submitted [_2]', $size, length $value ) if length $value < $size; }
The reason that we can't use the automatic pluralization feature of Locale::Maketext is that it doesn't support some of the languages we are using. We have to work around some incomplete localization features in some of the DateTime libraries also.
On Wed Jul 18 17:00:38 2012, PHRED wrote: Show quoted text
> I found two more instances of quant calls that needed the plural > message added. Currently we > cannot completely translate these error messages for when the plural > case is executed.
The point of the %Lexicon is for mapping. %Lexicon => ( 'limit to [quant,_1,character]' => 'limit to [quant,_1,letter,letters]', ); Won't that work? Show quoted text
> > --- lib/Form/Processor/Field.pm 2012-07-11 21:43:14.000000000 -0700 > +++ Field.pm 2012-07-18 13:57:19.062574455 -0700 > @@ -461,7 +461,7 @@ > my $value = $field->input; > > if ( length( $value ) > $size ) { > - $field->add_error( 'Please limit to [quant,_1,character]. > You submitted [_2]', $size, > length $value ); > + $field->add_error( 'Please limit to > [quant,_1,character,characters]. You submitted > [_2]', $size, length $value ); > return; > } > } > --- lib/Form/Processor/Field/Text.pm 2011-05-19 07:54:23.000000000 > -0700 > +++ Text.pm 2012-07-18 13:56:50.944099709 -0700 > @@ -31,7 +31,7 @@ > > my $value = $field->input; > > - return $field->add_error( 'Please limit to > [quant,_1,character]. You submitted [_2]', $size, > length $value ) > + return $field->add_error( 'Please limit to > [quant,_1,character,characters]. You submitted > [_2]', $size, length $value ) > if length $value > $size; > > } > @@ -39,7 +39,7 @@ > # Check for min length > if ( my $size = $field->min_length ) { > > - return $field->add_error( 'Input must be at least > [quant,_1,character]. You submitted > [_2]', $size, length $value ) > + return $field->add_error( 'Input must be at least > [quant,_1,character,characters]. You > submitted [_2]', $size, length $value ) > if length $value < $size; > > }
Yes, that example works. I'll go with that. We've been explicitly specifying the plural because it is a lot easier for translators to understand. Also we have stuff like: my $pattern = 'limit to [quant,_1,match]'; So the auto pluralization won't work with that (should be matches, but generates matchs).