[Jifty-commit] r1936 - in jifty/trunk: lib/Jifty t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Sep 6 11:05:05 EDT 2006
Author: jesse
Date: Wed Sep 6 11:05:05 2006
New Revision: 1936
Added:
jifty/trunk/t/10-i18n.t
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/I18N.pm
Log:
r27197 at pinglin: jesse | 2006-09-06 11:01:53 -0400
Sean E. Millichamp and clkao both pointed out that Locale::Maketext could choke on overloaded objects like DateTimes. This change makes sure that doesn't
happen any more.
Modified: jifty/trunk/lib/Jifty/I18N.pm
==============================================================================
--- jifty/trunk/lib/Jifty/I18N.pm (original)
+++ jifty/trunk/lib/Jifty/I18N.pm Wed Sep 6 11:05:05 2006
@@ -62,11 +62,14 @@
return undef unless (defined $_[0]);
local $@;
- my $result = eval { $lh->maketext(@_) };
+ # Force stringification to stop Locale::Maketext from choking on
+ # things like DateTime objects.
+ my @stringified_args = map {"$_"} @_;
+ my $result = eval { $lh->maketext(@stringified_args) };
if ($@) {
# Sometimes Locale::Maketext fails to localize a string and throws
# an exception instead. In that case, we just return the input.
- return join(' ', @_);
+ return join(' ', @stringified_args);
}
return $result;
};
Added: jifty/trunk/t/10-i18n.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/10-i18n.t Wed Sep 6 11:05:05 2006
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 1;
+
+use DateTime;
+use Jifty::Everything;
+
+my $dt = DateTime->new( year => 1950, month => 1, day => 1 );
+
+Jifty->new( no_handle => 1 );
+my $lh = Jifty::I18N->new();
+
+
+# the localization method used to break DateTime object stringification
+is($dt,_($dt));
+
+
More information about the Jifty-commit
mailing list