diff --git a/lib/WebGUI/International.pm b/lib/WebGUI/International.pm index 2201f22a3..f1e4b29c5 100644 --- a/lib/WebGUI/International.pm +++ b/lib/WebGUI/International.pm @@ -141,20 +141,21 @@ sub getLanguage { $file =~ s{::}{/}g; $file .= '.pm'; eval{require $file}; - unless ($@) { - $cmd = "\$".$cmd."::LANGUAGE"; - my $hashRef = eval($cmd); - $self->session->errorHandler->warn("Failed to retrieve language properties because ".$@) if ($@); - if ($property) { - return $hashRef->{$property}; - } - else { - return $hashRef; - } - } - else { + if ($@) { $self->session->errorHandler->warn("Language failed to compile: $language. ".$@); - } + return; + } + $cmd = '$'.$cmd.'::LANGUAGE'; + ## no critic ProhibitStringyEval + my $hashRef = eval($cmd); + ## use critic; + $self->session->errorHandler->warn("Failed to retrieve language properties because ".$@) if ($@); + if ($property) { + return $hashRef->{$property}; + } + else { + return $hashRef; + } } diff --git a/t/International.t b/t/International.t index 254a081a0..f1e576969 100644 --- a/t/International.t +++ b/t/International.t @@ -21,7 +21,7 @@ my $session = WebGUI::Test->session; my $numTests = 1; ##For conditional load check my $langTests = 2; ##For language look-up tests -$numTests += 10 + $langTests; +$numTests += 11 + $langTests; plan tests => $numTests; @@ -71,6 +71,8 @@ SKIP: { is($i18n->getLanguage('English', 'label'), 'English', 'getLanguage, specific property'); +isa_ok($i18n->getLanguage('English'), 'HASH', 'getLanguage, without a specific property returns a hashref'); + } sub installPigLatin {