.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Zonemaster::Engine::Translator 3pm" .TH Zonemaster::Engine::Translator 3pm 2024-04-22 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Zonemaster::Engine::Translator \- translation support for Zonemaster .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& Zonemaster::Engine::Translator\->initialize( { locale => \*(Aqsv_SE.UTF\-8\*(Aq } ); \& \& my $trans = Zonemaster::Engine::Translator\->instance; \& say $trans\->to_string($entry); .Ve .PP This is a singleton class. .PP The instance of this class requires exclusive control over \f(CW$ENV{LC_MESSAGES}\fR and the program's underlying LC_MESSAGES. At times it resets gettext's textdomain. On construction it unsets \f(CW$ENV{LC_ALL}\fR and from then on it must remain unset. .PP On systems that support \f(CW$ENV{LANGUAGE}\fR, this variable overrides the \fBlocale()\fR attribute unless the \fBlocale()\fR attribute is set to \f(CW"C"\fR. .SH ATTRIBUTES .IX Header "ATTRIBUTES" .IP locale 4 .IX Item "locale" The locale used for localized messages. .Sp .Vb 4 \& say $translator\->locale(); \& if ( !$translator\->locale( \*(Aqsv_SE.UTF\-8\*(Aq ) ) { \& say "failed to update locale"; \& } .Ve .Sp The value of this attribute is mirrored in \f(CW$ENV{LC_MESSAGES}\fR. .Sp When writing to this attribute, a request is made to update the program's underlying LC_MESSAGES. If this request fails, the attribute value remains unchanged and an empty list is returned. .Sp As a side effect when successfully updating this attribute gettext's textdomain is reset. .IP data 4 .IX Item "data" A reference to a hash with translation data. This is unlikely to be useful to end-users. .SH METHODS .IX Header "METHODS" .IP initialize(%args) 4 .IX Item "initialize(%args)" Provide initial values for the single instance of this class. .Sp .Vb 1 \& Zonemaster::Engine::Translator\->initialize( { locale => \*(Aqsv_SE.UTF\-8\*(Aq } ); .Ve .Sp This method must be called at most once and before the first call to \fBinstance()\fR. .IP \fBinstance()\fR 4 .IX Item "instance()" Returns the single instance of this class. .Sp .Vb 1 \& my $translator = Zonemaster::Engine::Translator\->instance; .Ve .Sp If \fBinitialize()\fR has not been called prior to the first call to \fBinstance()\fR, it is the same as if \fBinitialize()\fR had been called without arguments. .IP new(%args) 4 .IX Item "new(%args)" Use of this method is deprecated. .Sp See MooseX::Singleton\-new|MooseX::Singleton/"Singleton\->new">. .RS 4 .IP locale 4 .IX Item "locale" If no initial value is provided to the constructor, one is determined by calling setlocale( LC_MESSAGES, "" ). .RE .RS 4 .RE .IP to_string($entry) 4 .IX Item "to_string($entry)" Takes a Zonemaster::Engine::Logger::Entry object as its argument and returns a translated string with the timestamp, level, message and arguments in the entry. .IP translate_tag($entry) 4 .IX Item "translate_tag($entry)" Takes a Zonemaster::Engine::Logger::Entry object as its argument and returns a translation of its tag and arguments. .IP test_case_description($testcase) 4 .IX Item "test_case_description($testcase)" Takes a string (test case ID) and returns the translated test case description. .IP BUILD 4 .IX Item "BUILD" Internal method that's only mentioned here to placate Pod::Coverage.