[Jifty-commit] r2643 - jifty/trunk/lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jan 27 02:22:06 EST 2007
Author: audreyt
Date: Sat Jan 27 02:22:06 2007
New Revision: 2643
Modified:
jifty/trunk/lib/Jifty/Handler.pm
jifty/trunk/lib/Jifty/I18N.pm
Log:
* Support for dynamic language handles for Jifty::I18N,
so each request can trigger a different _() language.
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Sat Jan 27 02:22:06 2007
@@ -182,6 +182,8 @@
Jifty::I18N->refresh;
}
+ Jifty::I18N->get_language_handle;
+
$self->cgi( $args{cgi} );
$self->apache( HTML::Mason::FakeApache->new( cgi => $self->cgi ) );
Modified: jifty/trunk/lib/Jifty/I18N.pm
==============================================================================
--- jifty/trunk/lib/Jifty/I18N.pm (original)
+++ jifty/trunk/lib/Jifty/I18N.pm Sat Jan 27 02:22:06 2007
@@ -30,6 +30,7 @@
=cut
+my $DynamicLH;
sub new {
my $class = shift;
@@ -56,13 +57,14 @@
}
);
- $self->init;
-
# Allow hard-coded languages in the config file
my $lang = Jifty->config->framework('L10N')->{'Lang'};
$lang = [defined $lang ? $lang : ()] unless ref($lang) eq 'ARRAY';
- my $lh = $class->get_handle(@$lang);
+ my $lh = $class->get_handle(@$lang);
+ $DynamicLH = \$lh unless @$lang;
+ $self->init;
+
my $loc_method = sub {
# Retain compatibility with people using "-e _" etc.
return \*_ unless @_;
@@ -92,6 +94,17 @@
return $self;
}
+=head2 get_language_handle
+
+Get the lanauge language for this request.
+
+=cut
+
+sub get_language_handle {
+ my $self = shift;
+ $$DynamicLH = $self->get_handle() if $DynamicLH;
+}
+
=head2 refresh
Used by L<Jifty::Handler> in DevelMode to reload F<.po> files whenever they
More information about the Jifty-commit
mailing list