| 1 | package Zonemaster::Backend::Translator; | ||
| 2 | |||
| 3 | our $VERSION = '1.1.0'; | ||
| 4 | |||
| 5 | use 5.14.2; | ||
| 6 | |||
| 7 | use Moose; | ||
| 8 | use Encode; | ||
| 9 | use Readonly; | ||
| 10 | use POSIX qw[setlocale LC_MESSAGES LC_CTYPE]; | ||
| 11 | use Locale::TextDomain qw[Zonemaster-Backend]; | ||
| 12 | use Zonemaster::Backend::Config; | ||
| 13 | |||
| 14 | # Zonemaster Modules | ||
| 15 | require Zonemaster::Engine::Translator; | ||
| 16 | require Zonemaster::Engine::Logger::Entry; | ||
| 17 | |||
| 18 | extends 'Zonemaster::Engine::Translator'; | ||
| 19 | |||
| 20 | Readonly my %TAG_DESCRIPTIONS => ( | ||
| 21 | TEST_DIED => sub { | ||
| 22 | __x # BACKEND_TEST_AGENT:TEST_DIED | ||
| 23 | 'An error occured and Zonemaster could not start or finish the test.', @_; | ||
| 24 | }, | ||
| 25 | UNABLE_TO_FINISH_TEST => sub { | ||
| 26 | __x # BACKEND_TEST_AGENT:UNABLE_TO_FINISH_TEST | ||
| 27 | 'The test took too long to run (the current limit is {max_execution_time} seconds). ' | ||
| 28 | . 'Maybe there are too many name servers or the name servers are either unreachable or not responsive enough.', @_; | ||
| 29 | }, | ||
| 30 | ); | ||
| 31 | |||
| 32 | sub _build_all_tag_descriptions { | ||
| 33 | my ( $class ) = @_; | ||
| 34 | |||
| 35 | my $all_tag_descriptions = Zonemaster::Engine::Translator::_build_all_tag_descriptions(); | ||
| 36 | $all_tag_descriptions->{Backend} = \%TAG_DESCRIPTIONS; | ||
| 37 | return $all_tag_descriptions; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub translate_tag { | ||
| 41 | my ( $self, $hashref ) = @_; | ||
| 42 | |||
| 43 | my $entry = Zonemaster::Engine::Logger::Entry->new( { %{ $hashref } } ); | ||
| 44 | |||
| 45 | return decode_utf8( $self->SUPER::translate_tag( $entry ) ); | ||
| 46 | } | ||
| 47 | |||
| 48 | sub test_case_description { | ||
| 49 | my ( $self, $test_name ) = @_; | ||
| 50 | |||
| 51 | return decode_utf8( $self->SUPER::test_case_description( $test_name ) ); | ||
| 52 | } | ||
| 53 | |||
| 54 | 1; |