Skip to content

Commit

Permalink
Pass available languages too
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Apr 3, 2011
1 parent 1dd3135 commit 218f58d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/Lamework/Middleware/I18N.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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(@_));
};

Expand Down
4 changes: 2 additions & 2 deletions t/app_i18n.t
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};
5 changes: 4 additions & 1 deletion t/lib/MyAppI18N/Action/Foo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 218f58d

Please sign in to comment.