[Jifty-commit] r3043 - in jifty/trunk: lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Mar 21 15:39:45 EDT 2007
Author: jesse
Date: Wed Mar 21 15:39:43 2007
New Revision: 3043
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/I18N.pm
Log:
r53770 at pinglin: jesse | 2007-03-21 15:39:03 -0400
* Better plugin I18N
Alexey Grebenschikov wrote:
Plugin paths don't need to convert because File::ShareDir::module_dir
always returns an absolute path. I have added also modification checking
to the Jifty::I18N::refresh for plugin po files.
Modified: jifty/trunk/lib/Jifty/I18N.pm
==============================================================================
--- jifty/trunk/lib/Jifty/I18N.pm (original)
+++ jifty/trunk/lib/Jifty/I18N.pm Wed Mar 21 15:39:43 2007
@@ -7,6 +7,7 @@
use Email::MIME::ContentType;
use Encode::Guess qw(iso-8859-1);
use File::ShareDir ':ALL';
+use Jifty::Util;
=head1 NAME
@@ -48,18 +49,7 @@
my $self = {};
bless $self, $class;
- my @import = (
- 'Gettext',Jifty->config->framework('L10N')->{'PoDir'}. '/*.po',
- 'Gettext',Jifty->config->framework('L10N')->{'DefaultPoDir'}. '/*.po'
- );
-
- foreach my $plugin (Jifty->plugins) {
- local $@;
- my $dir = eval { module_dir(ref($plugin)); };
- next unless $dir;
- push @import, 'Gettext';
- push @import, $dir . '/po/*.po';
- };
+ my @import = map {( Gettext => $_ )} _get_file_patterns();
Locale::Maketext::Lexicon->import(
{ '*' => \@import,
@@ -108,6 +98,32 @@
return $self;
}
+=head2 _get_file_patterns
+
+Get list of patterns for all PO files in the project.
+(Paths are gotten from the configuration variables and plugins).
+
+=cut
+
+sub _get_file_patterns {
+ my @ret;
+
+ push(@ret, Jifty->config->framework('L10N')->{'PoDir'});
+ push(@ret, Jifty->config->framework('L10N')->{'DefaultPoDir'});
+
+ # Convert relative paths to absolute ones
+ @ret = map { Jifty::Util->absolute_path($_) } @ret;
+
+ foreach my $plugin (Jifty->plugins) {
+ local $@;
+ my $dir = eval { module_dir(ref($plugin)); };
+ next unless $dir;
+ push @ret, $dir . '/po';
+ }
+
+ return ( map { $_ . '/*.po' } @ret );
+}
+
=head2 get_language_handle
Get the lanauge language for this request.
@@ -130,10 +146,7 @@
sub refresh {
my $modified = join(
',',
- sort map { $_ => -M $_ } map { glob("$_/*.po") } (
- Jifty->config->framework('L10N')->{'PoDir'},
- Jifty->config->framework('L10N')->{'DefaultPoDir'}
- )
+ sort map { $_ => -M $_ } map { glob($_) } _get_file_patterns()
);
if ($modified ne $last_modified) {
Jifty::I18N->new;
More information about the Jifty-commit
mailing list