diff options
Diffstat (limited to 'lib/JWebmail/Plugin/I18N2.pm')
-rw-r--r-- | lib/JWebmail/Plugin/I18N2.pm | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/JWebmail/Plugin/I18N2.pm b/lib/JWebmail/Plugin/I18N2.pm index c951eec..61f87d6 100644 --- a/lib/JWebmail/Plugin/I18N2.pm +++ b/lib/JWebmail/Plugin/I18N2.pm @@ -125,8 +125,10 @@ sub register { } } - $app->defaults(default_language => $defaultLang); - $app->defaults(languages => [$t->languages]); + $app->defaults( + default_language => $defaultLang, + languages => [$t->languages], + ); # add translator as helper $app->helper(l => sub { @@ -142,16 +144,13 @@ sub register { return $res; }); - # modify incoming url - $app->hook(before_dispatch => sub { + # modify incoming and generated urls + $app->hook(before_routes => sub { my $c = shift; + unshift @{ $c->req->url->path->parts }, '' unless $t->languages($c->req->url->path->parts->[0] || ''); - }); - # modify generated url - $app->hook(before_dispatch => sub { - my $c = shift; $c->match(JWebmail::Plugin::I18N2::Match->new( root => $c->app->routes, _i18n2_stash => $c->stash, |