| 1 | # ============================================================================ | ||||||||||
| 2 | package CatalystX::I18N::TraitFor::Response; | ||||||||||
| 3 | # ============================================================================ | ||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | requires qw(headers); | |||||||||
| 8 | |||||||||||
| 9 | 33 | ▶ | sub content_language { | ||||||||
|
Subroutine
content_language: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 10 | 33 | my ($self,@languages) = @_; | |||||||||
| 11 | |||||||||||
| 12 | 33 | ▶ | if (scalar @languages) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 33 | my $language = join(', ',@languages); | |||||||||
| 14 | 33 | return $self->headers->header( 'Content-Language' => $language ); | |||||||||
| 15 | } else { | ||||||||||
| 16 | 0 | return $self->header->header( 'Content-Language' ); | |||||||||
| 17 | } | ||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 4 | ▶ | no Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 4 | 1; | |||||||||
| 22 | |||||||||||
| 23 | =encoding utf8 | ||||||||||
| 24 | |||||||||||
| 25 | =head1 NAME | ||||||||||
| 26 | |||||||||||
| 27 | CatalystX::I18N::TraitFor::Response - Adds the Content-Language header to the Catalyst::Response object | ||||||||||
| 28 | |||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||
| 30 | |||||||||||
| 31 | package MyApp::Catalyst; | ||||||||||
| 32 | |||||||||||
| 33 | use CatalystX::RoleApplicator; | ||||||||||
| 34 | use Catalyst qw/MyPlugins | ||||||||||
| 35 | CatalystX::I18N::Role::Base/; | ||||||||||
| 36 | |||||||||||
| 37 | __PACKAGE__->apply_response_class_roles(qw/CatalystX::I18N::TraitFor::Response/); | ||||||||||
| 38 | |||||||||||
| 39 | =head1 DESCRIPTION | ||||||||||
| 40 | |||||||||||
| 41 | This role simply adds the 'Content-Language' header to your response. | ||||||||||
| 42 | |||||||||||
| 43 | =head1 METHODS | ||||||||||
| 44 | |||||||||||
| 45 | =head3 content_language | ||||||||||
| 46 | |||||||||||
| 47 | $c->response->content_language('de_AT','en'); | ||||||||||
| 48 | |||||||||||
| 49 | Accepts a list of languages. This header will be automatically set | ||||||||||
| 50 | if you use it in conjunction with the L<CatalystX::I18N::Role::Base> role. | ||||||||||
| 51 | |||||||||||
| 52 | =head1 SEE ALSO | ||||||||||
| 53 | |||||||||||
| 54 | L<Catalyst::Respone> | ||||||||||
| 55 | |||||||||||
| 56 | =head1 AUTHOR | ||||||||||
| 57 | |||||||||||
| 58 | Maroš Kollár | ||||||||||
| 59 | CPAN ID: MAROS | ||||||||||
| 60 | maros [at] k-1.com | ||||||||||
| 61 | |||||||||||
| 62 | L<http://www.k-1.com> | ||||||||||