Skip to content

Commit

Permalink
fixed small code generation bug in Mojolicious::Plugin::I18N
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 5, 2012
1 parent 286403f commit e709659
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -12,6 +12,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Fixed bug that prevented helper names from ending with "begin".
- Fixed empty frame handling in Mojo::Transaction::WebSocket.
- Fixed small rendering bug in Mojolicious::Plugin::PODRenderer.
- Fixed small code generation bug in Mojolicious::Plugin::I18N.

2.92 2012-04-30
- Added commands attribute to Mojolicious.
Expand Down
20 changes: 10 additions & 10 deletions lib/Mojolicious/Plugin/I18N.pm
Expand Up @@ -10,15 +10,15 @@ sub register {
my ($self, $app, $conf) = @_;

# Initialize
my $namespace = $conf->{namespace} || ((ref $app) . "::I18N");
my $default = $conf->{default} || 'en';
eval "package $namespace; use base 'Locale::Maketext'; 1;";
eval "require ${namespace}::${default};";
unless (eval "\%${namespace}::${default}::Lexicon") {
eval "package ${namespace}::$default; use base '$namespace';"
. 'our %Lexicon = (_AUTO => 1); 1;';
die qq/Couldn't initialize I18N class "$namespace": $@/ if $@;
}
my $ns = $conf->{namespace} || ((ref $app) . "::I18N");
my $default = $conf->{default} || 'en';
die qq/Couldn't initialize I18N class "$ns": $@/
unless eval "package $ns; { use base 'Locale::Maketext'; 1 }";
my $dc = "${ns}::$default";
eval "require $dc;";
die qq/Couldn't initialize default lexicon class "$dc": $@/
unless eval "\%${dc}::Lexicon"
|| eval "package $dc; { use base '$ns'; our \%Lexicon = (_AUTO => 1); }";

# Add hook
$app->hook(
Expand All @@ -34,7 +34,7 @@ sub register {

# Handler
$self->stash->{i18n}
= Mojolicious::Plugin::I18N::_Handler->new(namespace => $namespace);
= Mojolicious::Plugin::I18N::_Handler->new(namespace => $ns);

# Languages
$self->stash->{i18n}->languages(@languages, $default);
Expand Down

0 comments on commit e709659

Please sign in to comment.