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;