[jifty-devel] PoDir isn't absolute
Jesse Vincent
jesse at bestpractical.com
Fri Mar 9 16:16:39 EST 2007
On Fri, Mar 09, 2007 at 03:31:48AM +0200, Alexey Grebenschikov wrote:
> On Wed, 2007-03-07 at 14:08 -0500, Jesse Vincent wrote:
> >
> > I think a cleaner patch would inspect the whole array afterward and
> > using absolute_path on its value then. Does that make sense?
> >
>
> Yes, you are right. I hope a new patch will be better.
> 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. Could you look at this
> patch?
Yes. this looks much better. Shall I apply it?
>
> Thanks
> Alexey.
> Index: lib/Jifty/I18N.pm
> ===================================================================
> --- lib/Jifty/I18N.pm (revision 2929)
> +++ lib/Jifty/I18N.pm (working copy)
> @@ -7,6 +7,7 @@
> use Email::MIME::ContentType;
> use Encode::Guess qw(iso-8859-1);
> use File::ShareDir ':ALL';
> +use Jifty::Util;
>
> =head1 NAME
>
> @@ -37,19 +38,8 @@
> my $self = {};
> bless $self, $class;
>
> - my @import = (
> - 'Gettext',Jifty->config->framework('L10N')->{'PoDir'}. '/*.po',
> - 'Gettext',Jifty->config->framework('L10N')->{'DefaultPoDir'}. '/*.po'
> - );
> + my @import = map {( Gettext => $_ )} _get_file_patterns();
>
> - foreach my $plugin (Jifty->plugins) {
> - local $@;
> - my $dir = eval { module_dir(ref($plugin)); };
> - next unless $dir;
> - push @import, 'Gettext';
> - push @import, $dir . '/po/*.po';
> - };
> -
> Locale::Maketext::Lexicon->import(
> { '*' => \@import,
> _decode => 1,
> @@ -97,6 +87,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.
> @@ -119,10 +135,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-devel
mailing list