Zonemaster::Engine::Translator(3pm) | User Contributed Perl Documentation | Zonemaster::Engine::Translator(3pm) |
Zonemaster::Engine::Translator - translation support for Zonemaster
Zonemaster::Engine::Translator->initialize({ locale => 'sv_SE.UTF-8' }); my $trans = Zonemaster::Engine::Translator->instance; say $trans->to_string($entry);
This is a singleton class.
The instance of this class requires exclusive control over $ENV{LC_MESSAGES} and the program's underlying LC_MESSAGES. At times it resets gettext's textdomain. On construction it unsets $ENV{LC_ALL} and from then on it must remain unset.
On systems that support $ENV{LANGUAGE}, this variable overrides the locale() attribute unless the locale() attribute is set to "C".
say $translator->locale(); if ( !$translator->locale( 'sv_SE.UTF-8' ) ) { say "failed to update locale"; }
The value of this attribute is mirrored in $ENV{LC_MESSAGES}.
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.
As a side effect when successfully updating this attribute gettext's textdomain is reset.
Zonemaster::Engine::Translator->initialize( locale => 'sv_SE.UTF-8' );
This method must be called at most once and before the first call to instance().
my $translator = Zonemaster::Engine::Translator->instance;
If initialize() has not been called prior to the first call to instance(), it is the same as if initialize() had been called without arguments.
See MooseX::Singleton-new|MooseX::Singleton/"Singleton->new">.
2023-03-04 | perl v5.36.0 |