Log::R...on::PO(3pm)
π Log::Report::Lexicon::PO β one translation definition π
okay bestie, so this module (it's Log::R...on::PO(3pm) in the Perl docs, no cap) is literally the vibe of one single translation definition. Think of it as one lil PO record, being the main character. Sets of these PO records get kept together in a POT file, which is its own whole thing β Log::Report::Lexicon::POT. iykyk π«Ά
β¨ SYNOPSIS β¨
(no synopsis here bestie, the pod said nothing and honestly? iconic of it π )
πΈ DESCRIPTION πΈ
So basically: this module is administering one translation object. One. Singular. Main character energy only. π
And the sets of PO records? Those hang out in a POT file, which is implemented over in Log::Report::Lexicon::POT. Besties, they're a matched set. π
π¦ METHODS π¦
π§ Constructors π§
$class->new(%options)
here's the options table, hun, straight up:
-Option --Default
automatic ""
comment []
format []
fuzzy false
msgctxt undef
msgid <required>
msgid_plural undef
msgstr "" or []
references []
and now the tea on each one:
automatic=> PARAGRAPH β these are comments that got added automatically. SeeaddAutomatic(). π€comment=> PARAGRAPH β comments the translator added themselves. SeeaddComment(). π¬format=> ARRAY|HASH β seeformat(). You can hand it either an ARRAY full of PAIRS, or a HASH with that same info in it. Either one, we're flexible. πfuzzy=> BOOLEAN β the string isn't translated yet, and some smart guesses may or may not have been made. Seefuzzy(). πmsgctxt=> STRING β the context string: text sitting around the msgid itself.msgid=> STRINGmsgid_plural=> STRINGmsgstr=> STRING|ARRAY-OF-STRING β the translations for the msgid. β οΈ Heads up: whenmsgid_pluralis defined, you must provide an ARRAY, no shortcuts.references=> STRING|ARRAY-OF-LOCATIONS β the STRING is a blank separated list of LOCATIONS. A LOCATION looks like"filename:linenumber", for instance"lib/Foo.pm:42". SeeaddReferences(). π
π Attributes π
$obj->addAutomatic(LIST|ARRAY|STRING)β adds multiple lines to the translator's comment block. Returns an empty string if there are no comments. (yes, same description as below, the pod said it twice and I'm not erasing it, periodt)$obj->addComment(LIST|ARRAY|STRING)β adds multiple lines to the translator's comment block. Returns an empty string if there are no comments. π¬$obj->addFlags(STRING)β parses a"flags"line. π©$obj->addReferences(STRING|LIST|ARRAY)β theSTRINGis a blank separated list of LOCATIONS. TheLISTandARRAYhold separate LOCATIONS. A LOCATION is of the form"filename:linenumber". Returns the internal HASH with references. π$obj->automatic( [LIST|ARRAY|STRING] )β returns aSTRINGcontaining the cleaned paragraph of automatically added comments. If you pass an argument, it replaces the current comment. β¨$obj->comment( [LIST|ARRAY|STRING] )β returns aSTRINGcontaining the cleaned paragraph of the translator's comment. If you pass an argument, it replaces the current comment. π¬$obj->format( $language | <PAIRS|ARRAY|HASH> )β when you hand it one$language, it checks whether a"language-format"or"no-language-format"is present in the line of FLAGS. Returns1("true") in the first case,0("false") in the second. And if neither one is there? It returnsundef(which is also"false"). π«
You can also specify PAIRS: the key is a language name, and the value is either 0, 1, or undef.
Β» example: use of format()
# getters
if($po->format('c')) ...
unless($po->format('perl-brace')) ...
if(defined $po->format('java')) ...
# setters
$po->format(java => 1); # results in 'java-format'
$po->format(java => 0); # results in 'no-java-format'
$po->format(java => undef); # results in ''
$obj->fuzzy( [BOOLEAN] )β returns whether the translation needs human inspection. π$obj->isActive()β returns whether the translation has any references, or is the header. π’$obj->keepReferencesTo($table)β removes all references that aren't found as a key in the hash$table. Returns the number of references left. π§Ή$obj->msgctxt()β returns the message context, if one was provided.$obj->msgid()β returns the actual msgid, which cannot beundef. (it's giving required, fr fr)$obj->msgstr( [$index, [STRING]] )β with aSTRING, a new translation gets set. Without aSTRING, a lookup happens instead. When no plural is defined, the$indexis just ignored, no biggie.$obj->plural( [STRING] )β returns the actualmsgid_plural, which can beundef.$obj->references( [STRING|LIST|ARRAY] )β returns an unsorted list of LOCATIONS. When options are specified, those get used to replace all currently defined references. Returns the unsortedLISTof references. π$obj->removeReferencesTo($filename)β removes all the references to the indicated$filenamefrom the list. Returns the number of refs left. π§Ή
π Parsing π
$class->fromText( STRING, [$where] )β parses theSTRINGinto a brand new PO object. The$wherestring should explain where theSTRINGcame from, so error messages can point at it. π$obj->toString(%options)β formats the object into a multi-lined string. π
-Option --Default
nr_plurals undef
nr_plurals=> INTEGER β if the number of plurals is specified, then the plural translation list can be checked for the correct length. Otherwise, no smart behavior is attempted. (we simply do not try π)
$obj->useless()β[1.02]the message-id has no references anymore and no translations. ποΈ
π DIAGNOSTICS π
- Warning: do not understand command
'$cmd'at$whereβ Cast byfromText() - Warning: do not understand line at
$where:\n $lineβ Cast byfromText() - Error: no msgid defined for PO β Cast by
new() - Warning: no msgid in block
$whereβ Cast byfromText() - Warning: no plurals for
'$msgid'β Cast bytoString() - Warning: quoted line is not a continuation at
$whereβ Cast byfromText() - Warning: too many plurals for
'$msgid'β Cast bytoString() - Warning: unknown comment type
'$cmd'at$whereβ Cast byfromText() - Warning: unknown flag
$flagignored β Cast byaddFlags()
π SEE ALSO π
This module is part of Log-Report-Lexicon version 1.15, built on November 06, 2025. Website: http://perl.overmeer.net/CPAN/ π
π LICENSE π
For contributors see file ChangeLog. π
This software is copyright (c) 2007-2025 by Mark Overmeer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, legally speaking β¨
and that's the whole page bestie π«Ά this was perl v5.40.1, page dated 2025-11-11, from the Perl documentation you know and love β go forth and translate responsibly, ily π
π¦ where this page comes from
- ubuntu resolute: liblog-report-lexicon-perl 1.15-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblog-report-lexicon-perl 1.15-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms