Subject: | Problems with Locales::Base |
The problem lies in how strings are interpreted, at least on perl 5.10.
"$caller::something" is not $caller . "::something".
The included patch fixes this so that fallback works, and also fixes
some uninitialized warnings if the _getDefaultLocale returns undef
(which it does on my mac os x at least, since none of the ENV variables
are set).
Subject: | patch.diff |
--- Base.pm.orig 2008-03-25 13:06:35.000000000 +0100
+++ Base.pm 2008-03-25 13:07:03.000000000 +0100
@@ -46,7 +46,7 @@
{
my ($caller) = @_;
- my $module = "$caller::$FALLBACK_LOCALE";
+ my $module = $caller . "::$FALLBACK_LOCALE";
eval "require $module;"
|| die "Unable to load $module : $@";
@@ -67,7 +67,6 @@
my $self = {};
my $blessing = bless ( $self, $class );
-
if ( $class =~ /::Language/ ) {
$self->{_module} = "Locales::Language";
}
@@ -98,6 +97,7 @@
$locale ||= _getImportLocale ( $caller );
$locale ||= _getDefaultLocale;
+# warn "caller: $caller locale: $locale";
#
# check cache:
#
@@ -115,11 +115,14 @@
my $module = $caller."::$locale";
# print "C/M: $caller/$module\n";
+# warn "module: $module";
+
unless ( eval "require $module;" ) {
my $defaultLocale = _getDefaultLocale;
- if ( $locale eq $defaultLocale ) {
- warn ( "$defaultLocale is unsupported, trying $FALLBACK_LOCALE" );
- $object = _loadFallBackLocale;
+
+ if ( !defined($defaultLocale) || $locale eq $defaultLocale ) {
+ warn ( ($defaultLocale ? $defaultLocale : "undefined") . " is unsupported, trying $FALLBACK_LOCALE" );
+ $object = _loadFallBackLocale($caller);
}
else {
warn ( "$locale is unsupported, trying $defaultLocale" );
@@ -136,7 +139,7 @@
}
}
else {
- eval "require $caller::Base" unless ( $LOADS{$caller} );
+ eval( "require $caller . '::Base'") unless ( $LOADS{$caller} );
$LOADS{$caller} = 1;
#
# inheritance wonk, most reference 'new' from base class