diff --git a/lib/Lamework/Middleware/I18N.pm b/lib/Lamework/Middleware/I18N.pm index 0bcef64..301f118 100644 --- a/lib/Lamework/Middleware/I18N.pm +++ b/lib/Lamework/Middleware/I18N.pm @@ -64,8 +64,9 @@ sub call { my $handle = $class->get_handle(@languages); $handle->fail_with(sub { $_[1] }); - $env->{'lamework.i18n.language'} = $handle->language_tag; - $env->{'lamework.i18n.maketext'} = sub { + $env->{'lamework.i18n.language'} = $handle->language_tag; + $env->{'lamework.i18n.languages'} = [$self->available_languages]; + $env->{'lamework.i18n.maketext'} = sub { return Encode::decode_utf8($handle->maketext(@_)); }; diff --git a/t/app_i18n.t b/t/app_i18n.t index 28395cf..6cbe13a 100644 --- a/t/app_i18n.t +++ b/t/app_i18n.t @@ -16,8 +16,8 @@ test_psgi $app, sub { my $cb = shift; my $res = $cb->(GET '/'); - is $res->content, 'http://localhost/en'; + is $res->content, 'http://localhost/en,en,ru|en'; $res = $cb->(GET '/ru'); - is $res->content, 'http://localhost/ru'; + is $res->content, 'http://localhost/ru,ru,ru|en'; }; diff --git a/t/lib/MyAppI18N/Action/Foo.pm b/t/lib/MyAppI18N/Action/Foo.pm index 0bcf2b7..b56802e 100644 --- a/t/lib/MyAppI18N/Action/Foo.pm +++ b/t/lib/MyAppI18N/Action/Foo.pm @@ -5,8 +5,11 @@ use base 'Lamework::Action'; sub run { my $self = shift; + my $language = $self->env->{'lamework.i18n.language'}; + my $languages = $self->env->{'lamework.i18n.languages'}; + $self->res->code(200); - $self->res->body($self->url_for('foo')); + $self->res->body(join ',' => $self->url_for('foo'), $language, join '|', @$languages); } 1;