Zonema...slator(3pm)
π Zonemaster::Engine::Translator β aka the translation bestie π
okay so this is the page for Zonemaster::Engine::Translator(3pm) β it's part of the User Contributed Perl Documentation and it's basically the translator support for Zonemaster. she speaks every language, no cap π
β¨ SYNOPSIS β¨
Zonemaster::Engine::Translator->initialize( locale => 'sv_SE.UTF-8' );
my $trans = Zonemaster::Engine::Translator->instance;
say $trans->to_string($entry);
bestie, listen β this is a singleton class. one instance, one queen, no duplicates periodt π
so the way this works: the instance of this class needs exclusive control over $ENV{LC_MESSAGES} and the program's underlying LC_MESSAGES. like, nobody else gets to touch them. also at times it resets gettext's textdomain. and on construction it unsets $ENV{LC_ALL}, and from then on it must remain unset. fr fr, don't go re-setting it, that's not the vibe π«
on systems that support $ENV{LANGUAGE}, this variable overrides the locale() attribute β unless the locale() attribute is set to "C". so "C" is the one thing that fights back, iconic π
πΈ ATTRIBUTES πΈ
localeβ the locale used for localized messages. the whole glow-up language situation π«
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}. cute, right? π
when you write to this attribute, a request is made to update the program's underlying LC_MESSAGES. and if that request fails? the attribute value stays exactly as it was and an empty list is returned. no update, no drama, we move on π«Ά
and as a side effect, when this attribute is successfully updated, gettext's textdomain gets reset. just so you know β¨
dataβ a reference to a hash with translation data. ngl this one is unlikely to be useful to end-users, it's giving internal πall_tag_descriptionsβ that's it. that's the whole entry. she's mysterious, she's lowkey serving main character energy with no description π
π₯ METHODS π₯
initialize(%args)β gives you the initial values for the single instance of this class. you literally do this:
Zonemaster::Engine::Translator->initialize( locale => 'sv_SE.UTF-8' );
important: this method must be called at most once, and it has to happen before the first call to instance(). not twice, not after. read the rules bestie π
instance()β returns the single instance of this class. the one and only, the main character π
my $translator = Zonemaster::Engine::Translator->instance;
and if initialize() was never called before that first instance() call? it's the same as if initialize() had been called without any arguments. she just shows up fully formed, no cap β¨
new(%args)β π¨ use of this method is deprecated. yeah, deprecated deprecated. we don't do that here anymore πlocaleβ if no initial value is provided to the constructor, one is determined by callingsetlocale( LC_MESSAGES, "" ). so it goes and figures it out itself, independent queen π
to_string($entry)β takes aZonemaster::Engine::Logger::Entryobject as its argument and returns a translated string with the timestamp, level, message and arguments in the entry. all four, bundled up, one pretty string, we love a glow-up πΈtranslate_tag($entry)β takes aZonemaster::Engine::Logger::Entryobject as its argument and returns a translation of its tag and arguments. just the tag and args, no timestamp, no message πtest_case_description($testcase)β takes a string (a test case ID) and returns the translated test case description. hand her an ID, she hands you words π₯BUILDβ internal method that's only mentioned here to placatePod::Coverage. yes, she's literally just here so the coverage checker stops side-eyeing us π
β quick recap so you don't fumble: callinitialize()once, beforeinstance(), keep$ENV{LC_ALL}unset forever, and remember that$ENV{LANGUAGE}runs the show unlesslocale()is"C". slay responsibly π«Ά
and that's the whole page bestie!! this one was documented as perl v5.40.1, dated 2026-03-21, from the Zonema...slator(3pm) page β so go forth and translate the entire internet, you've got this πβ¨ππ¦
π¦ where this page comes from
- ubuntu stonking: libzonemaster-perl 8.001.001-1 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms