| 1 | package HTML::FormHandler::TraitFor::I18N; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: localization | ||||||||||||||||||||||||||||
| 3 | 147 | $HTML::FormHandler::TraitFor::I18N::VERSION = '0.410002'; | |||||||||||||||||||||||||||
| 4 | 147 | ▶ | use HTML::FormHandler::I18N; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 147 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 147 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 147 | has 'language_handle' => ( | |||||||||||||||||||||||||||
| 10 | isa => duck_type( [ qw(maketext) ] ), | ||||||||||||||||||||||||||||
| 11 | is => 'rw', | ||||||||||||||||||||||||||||
| 12 | lazy_build => 1, | ||||||||||||||||||||||||||||
| 13 | required => 1, | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 145 | ▶ | sub _build_language_handle { | ||||||||||||||||||||||||||
|
Subroutine
_build_language_handle: called CC=5 SCAR=17.6
| |||||||||||||||||||||||||||||
| 17 | 145 | my ($self) = @_; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 145 | ▶ | if (!$self->isa('HTML::FormHandler') && $self->has_form) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->isa("HTML::FormHandler") and $self->has_form
MC/DC0%0/2
not $self->isa("HTML::FormHandler") and $self->has_form
not $self->isa("HTML::FormHandler")
$self->has_form
Truth table33%1/3
not(A) and B
A= not $self->isa("HTML::FormHandler")B= $self->has_form
| |||||||||||||||||||||||||||||
| 20 | 0 | return $self->form->language_handle(); | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | 145 | my $lh; | |||||||||||||||||||||||||||
| 23 | 145 | ▶ | if ( $ENV{LANGUAGE_HANDLE} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 31 | ▶ | if ( blessed $ENV{LANGUAGE_HANDLE} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | $lh = $ENV{LANGUAGE_HANDLE}; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | else { | ||||||||||||||||||||||||||||
| 28 | 31 | $lh = HTML::FormHandler::I18N->get_handle( $ENV{LANGUAGE_HANDLE} ); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||
| 32 | 114 | $lh = HTML::FormHandler::I18N->get_handle; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 145 | return $lh; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 20 | ▶ | sub _localize { | ||||||||||||||||||||||||||
|
Subroutine
_localize: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 20 | my ($self, @message) = @_; | |||||||||||||||||||||||||||
| 39 | 20 | my $message = $self->language_handle->maketext(@message); | |||||||||||||||||||||||||||
| 40 | 20 | return $message; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 147 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 147 | ▶ | no Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 147 | 1; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||