[Jifty-commit] r2082 - in jifty/trunk/lib: .
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun Oct 29 20:10:57 EST 2006
Author: audreyt
Date: Sun Oct 29 20:10:56 2006
New Revision: 2082
Modified:
jifty/trunk/lib/Jifty.pm
jifty/trunk/lib/Jifty/Handler.pm
jifty/trunk/lib/Jifty/I18N.pm
Log:
* Jifty::I18N: New ->refresh method so .po files are reloaded
properly when DevelMode is on.
Modified: jifty/trunk/lib/Jifty.pm
==============================================================================
--- jifty/trunk/lib/Jifty.pm (original)
+++ jifty/trunk/lib/Jifty.pm Sun Oct 29 20:10:56 2006
@@ -115,7 +115,7 @@
# Load the configuration. stash it in ->config
Jifty->config( Jifty::Config->new() );
- Jifty::I18N->new(); # can't do this before we have the config set up
+ Jifty::I18N->refresh(); # can't do this before we have the config set up
# Now that we've loaded the configuration, we can remove the temporary
# Jifty::DBI::Record baseclass for records and insert our "real" baseclass,
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Sun Oct 29 20:10:56 2006
@@ -178,7 +178,11 @@
@_
);
- Module::Refresh->refresh if ( Jifty->config->framework('DevelMode') );
+ if ( Jifty->config->framework('DevelMode') ) {
+ Module::Refresh->refresh;
+ Jifty::I18N->refresh;
+ }
+
$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 Sun Oct 29 20:10:56 2006
@@ -21,7 +21,6 @@
=cut
-
=head2 new
Set up Jifty's internationalization for your application. This pulls
@@ -85,6 +84,30 @@
return $self;
}
+=head2 refresh
+
+Used by L<Jifty::Handler> in DevelMode to reload F<.po> files whenever they
+are modified on disk.
+
+=cut
+
+my $last_modified = '';
+sub refresh {
+ my $modified = join(
+ ',',
+ sort map { $_ => -M $_ } map { glob("$_/*.po") } (
+ Jifty->config->framework('L10N')->{'PoDir'},
+ Jifty->config->framework('L10N')->{'DefaultPoDir'}
+ )
+ );
+ if ($modified ne $last_modified) {
+ Jifty::I18N->new;
+ $last_modified = $modified;
+ }
+}
+
+
+
=head2 promote_encoding STRING [CONTENT-TYPE]
Return STRING promoted to our best-guess of an appropriate
More information about the Jifty-commit
mailing list