Skip Menu |

This queue is for tickets about the Math-Currency CPAN distribution.

Report information
The Basics
Id: 32805
Status: resolved
Priority: 0/
Queue: Math-Currency

People
Owner: Nobody in particular
Requestors: cpan [...] desert-island.me.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.46
Fixed in: (no value)



Subject: Only copes with one EUR locale at a time (patch included)
Here's a patch to allow creation of more than one EUR based locale (or indeed any other). This allows me to have both en_IE and de_DE formatting in the same program. It also patches new_currency to create locale-based files, if the old behaviour is also desired, we could add a flag. diff -r -u Math-Currency-0.46/lib/Math/Currency.pm Math-Currency-0.46- new/lib/Math/Currency.pm --- Math-Currency-0.46/lib/Math/Currency.pm 2007-09-23 13:20:16.000000000 +0100 +++ Math-Currency-0.46-new/lib/Math/Currency.pm 2008-01-30 17:05:46.289615000 +0000 @@ -99,10 +99,10 @@ my $currency = shift; my $format; - if ( not defined $currency and $class =~ /$PACKAGE\:\:([A-Z]{3})/ ) { + if ( not defined $currency and $class->isa($PACKAGE) ) { # must be one of our subclasses - $currency = $1; + $currency = $1 if($class =~ /$PACKAGE\:\:(\w+)/); } if ( defined $currency ) #override default currency type diff -r -u Math-Currency-0.46/scripts/new_currency Math-Currency-0.46- new/scripts/new_currency --- Math-Currency-0.46/scripts/new_currency 2007-09-23 13:20:16.000000000 +0100 +++ Math-Currency-0.46-new/scripts/new_currency 2008-01-30 16:54:42.238959000 +0000 @@ -28,8 +28,9 @@ die "Cannot determine your locale currency format" unless Math::Currency->localize( \$format ); -my $localename = $format->{INT_CURR_SYMBOL}; -$localename =~ s/([A-Z]{3})./$1/; +# my $localename = $format->{INT_CURR_SYMBOL}; +# $localename =~ s/([A-Z]{3})./$1/; +my $localename = $lang; my $localesub = <<EOL; #!/usr/bin/perl -w package Math::Currency::$localename;
On Wed Jan 30 12:12:08 2008, JROBINSON wrote: Show quoted text
> Here's a patch to allow creation of more than one EUR based locale
(or Show quoted text
> indeed any other). This allows me to have both en_IE and de_DE > formatting in the same program. It also patches new_currency to
create Show quoted text
> locale-based files, if the old behaviour is also desired, we could
add Show quoted text
> a flag.
I added some more to unknown_currency, to make it cope with finding them on the fly too: diff -r -u Math-Currency-0.46/lib/Math/Currency.pm Math-Currency-0.46- new/lib/Math/Currency.pm --- Math-Currency-0.46/lib/Math/Currency.pm 2007-09-23 13:20:16.000000000 +0100 +++ Math-Currency-0.46-new/lib/Math/Currency.pm 2008-01-30 17:27:48.558873000 +0000 @@ -99,10 +99,10 @@ my $currency = shift; my $format; - if ( not defined $currency and $class =~ /$PACKAGE\:\:([A-Z]{3})/ ) { + if ( not defined $currency and $class->isa($PACKAGE) ) { # must be one of our subclasses - $currency = $1; + $currency = $1 if($class =~ /$PACKAGE\:\:(\w+)/); } if ( defined $currency ) #override default currency type @@ -372,10 +372,11 @@ chomp; setlocale( LC_ALL, $_ ); my $localeconv = POSIX::localeconv(); - if ( defined $localeconv->{'int_curr_symbol'} - and $localeconv->{'int_curr_symbol'} =~ /$currency/ ) + if ( $_ eq $currency || (defined $localeconv- Show quoted text
>{'int_curr_symbol'}
+ and $localeconv- Show quoted text
>{'int_curr_symbol'} =~ /$currency/ ))
{ my $format = \$LC_MONETARY->{$currency}; + my $format = \$LC_MONETARY->{$_}; Math::Currency->localize($format); last; } diff -r -u Math-Currency-0.46/scripts/new_currency Math-Currency-0.46- new/scripts/new_currency --- Math-Currency-0.46/scripts/new_currency 2007-09-23 13:20:16.000000000 +0100 +++ Math-Currency-0.46-new/scripts/new_currency 2008-01-30 16:54:42.238959000 +0000 @@ -28,8 +28,9 @@ die "Cannot determine your locale currency format" unless Math::Currency->localize( \$format ); -my $localename = $format->{INT_CURR_SYMBOL}; -$localename =~ s/([A-Z]{3})./$1/; +# my $localename = $format->{INT_CURR_SYMBOL}; +# $localename =~ s/([A-Z]{3})./$1/; +my $localename = $lang; my $localesub = <<EOL; #!/usr/bin/perl -w package Math::Currency::$localename;
Sorry this took so long to get into a production release. I just pushed 0.47 to CPAN last night... John