Log::R...on::POT(3pm)
โจ NAME โจ
Log::R...on::POT(3pm) โ this is the manual page for it, bestie ๐ โ and what it does is manage PO files. That's the whole vibe.
๐งฌ INHERITANCE ๐งฌ
Log::Report::Lexicon::POT
is a Log::Report::Lexicon::Table
So like, it's a Table, but make it POT-flavoured ๐
๐ SYNOPSIS ๐
okay so heads up: this is usually not for end-users, see ::Extract::PerlPPI. Got it? Cool. Now watch:
# this is usually not for end-users, See ::Extract::PerlPPI
# using a PO table
my $pot = Log::Report::Lexicon::POT->read('po/nl.po', charset => 'utf-8')
or die;
my $po = $pot->msgid('msgid');
my $po = $pot->msgid($msgid, $msgctxt);
print $pot->nrPlurals;
print $pot->msgstr('msgid', 3);
print $pot->msgstr($msgid, 3, $msgctxt);
$pot->write; # update the file
# fill the table, by calling the next a lot
my $po = Log::Report::Lexicon::PO->new(...);
$pot->add($po);
# creating a PO table
$pot->write('po/nl.po')
or die;
that last one or die is doing the lord's work, protect it ๐ซถ
๐ธ DESCRIPTION ๐ธ
This module is out here reading, extending, and writing POT files. POT files store translations in a humanly readable format for basically every translation framework that exists โ we're talking GNU gettext and Perl's Maketext. Iconic. ๐
ngl tho, if all you want to do is access the translation, you should use the much more efficient Log::Report::Lexicon::POTcompact instead. She's slimmer and faster, no shade to POT.
The code is loosely based on Locale::PO, by Alan Schwartz. The coding style is a bit off from the rest of "Log::Report", and there was a genuine need for sincere simplification. Every single PO record gets represented by a Log::Report::Lexicon::PO.
Extends "DESCRIPTION" in Log::Report::Lexicon::Table.
๐ ๏ธ METHODS ๐ ๏ธ
Extends "METHODS" in Log::Report::Lexicon::Table.
๐ง Constructors ๐ง
Extends "Constructors" in Log::Report::Lexicon::Table.
$class->new(%options)
Creates a brand new POT file, bestie. The initial header is generated for you (so generous of it), but you can change it later with the header() method.
Here's the default situation ๐:
-Option --Default
charset 'UTF-8'
date now
filename undef
index {}
nr_plurals 2
plural_alg n!=1
plural_forms <constructed from nr_plurals and plural_alg>
textdomain <required>
version undef
charset => STRINGโ the charset for the created file. It is unwise to use anything other than'UTF-8', but you're allowed. Before[1.09]this option was required, so count your blessings โจdate => STRINGโ overrule the date that gets baked into the generated header.filename => STRINGโ specify an output filename. You can also just hand it over whenwrite()is called, whatever's easier.index => HASHโ a whole set of translations (Log::Report::Lexicon::POobjects), keyed bymsgid.nr_plurals => INTEGERโ how many translations each translation with a plural form needs to have.plural_alg => EXPRESSIONโ the algorithm used to figure out which translatedmsgstrto use.plural_forms => RULEโ[0.992]when you use this option it overrules"nr_plurals"and"plural_alg". TheRULEshould be a full"Plural-Forms"field. She said "I'll take it from here" ๐textdomain => STRINGโ the package name, used in the directory structure for storing the PO files.version => STRINGโ yeah. just that. ๐
$class->read($filename, %options)
Reads the POT info straight out of $filename.
-Option --Default
charset <required>
charset => STRINGโ the character-set used for the file. You must specify this explicitly, no defaults, no shortcuts, no vibes-based guessing ๐
$obj->write( [$filename|$fh], %options )
When you pass an open $fh, you are the one responsible for making sure the correct character-encoding (binmode) is set. That's on you, bestie. But when the write follows a read() โ or the filename was explicitly set with filename() โ then you get to skip the first parameter entirely. So relaxed.
-Option --Default
only_active false
only_active => BOOLEANโ[1.02]don't write records that do have a translation but whosemsgidhas disappeared from the sources. By default, those records get commented out (marked with'#~') but left in the file. She's not ghosting them, just putting them on ice ๐ง
๐ฎ Attributes ๐ฎ
Extends "Attributes" in Log::Report::Lexicon::Table.
$obj->charset()โ the character-set used for reading and writing. You do not need to be aware of Perl's internal encoding for the characters. Phew.$obj->filename()โ returns the filename, derived fromread()or specified during initiation withnew(filename).$obj->index()โ returns aHASHof all defined PO objects, organized bymsgid. But please, try to avoid using this? Usemsgid()for lookup andadd()for adding translations. This is the "don't touch the thing directly" situation ๐ญ$obj->language()โ returns the language code, which is derived from the filename.
๐ Managing PO's ๐
Extends "Managing PO's" in Log::Report::Lexicon::Table.
$obj->keepReferencesTo($table)โ removes every reference that isn't found as a key in the hash$table. Returns the number of references left.$obj->removeReferencesTo($filename)โ removes all the references to the indicated$filenamefrom all defined translations. Returns the number of refs left.$obj->stats()โ returns aHASHwith some statistics about this POT table. Numbers! ๐$obj->updated( [$date] )โ replaces the"PO-Revision-Date"with the specified$date, or with the current moment if you don't bother.
๐ฆ Translation ๐ฆ
Extends "Translation" in Log::Report::Lexicon::Table.
$obj->msgid( STRING, [$msgctxt] )โ looks up theLog::Report::Lexicon::POmatching the"STRING". Wanna add a new translation? Useadd(). Returns"undef"when it's not defined. Improves base, see"Translation"in Log::Report::Lexicon::Table$obj->msgstr( $msgid, [$count, [$msgctxt]] )โ returns the translated string for$msgid. When$countisn't specified or is"undef", you get the translation string related to"1". Improves base, see"Translation"in Log::Report::Lexicon::Table
๐ Administration ๐
Extends "Administration" in Log::Report::Lexicon::Table.
$obj->add($po)โ adds the info from a$pointo this POT. If themsgidof the$pois already known? That's an error, no cap. Improves base, see"Administration"in Log::Report::Lexicon::Table$obj->header( [$field, [$content]] )โ the translation of a blank MSGID is used to store a MIME header, which holds some meta-data. When you only specify a$field, that content gets looked up (case-insensitive) and returned. When you specify a$content, the knowledge gets stored โ and in that case the header structure may get created. Set the$contentto"undef"and the field gets removed. Improves base, see"Administration"in Log::Report::Lexicon::Table$obj->nrPlurals()โ inherited, see"Administration"in Log::Report::Lexicon::Table$obj->pluralIndex($count)โ inherited, see"Administration"in Log::Report::Lexicon::Table$obj->setupPluralAlgorithm()โ inherited, see"Administration"in Log::Report::Lexicon::Table$obj->translations( [$active] )โ returns a list with all definedLog::Report::Lexicon::POobjects. When the string$activeis given as a parameter, only the objects that have references come back. Improves base, see"Administration"in Log::Report::Lexicon::Table
๐ DIAGNOSTICS ๐
the way this module is very honest about everything that can go wrong. we love a transparent king ๐ฅ
- Error: cannot detect charset in
$fnโ cast byread() - Fault: cannot read from file
$fn(unknown charset):$!โ cast byread() - Fault: cannot read in
$csfrom file$fn:$!โ cast byread() - Fault: cannot write to file
$fnwith$layers:$!โ cast bywrite() - Fault: failed reading from file
$fn:$!โ cast byread() - Error: invalid plural-form algorithm
'$alg'โ cast bysetupPluralAlgorithm() - Error: no filename or file-handle specified for PO โ when a PO file gets written, a filename or file-handle must be specified explicitly, or set beforehand using the
filename()method, or known because the write follows aread()of the file. Cast bywrite() - Error: no filename or file-handle specified for PO โ cast by
write() - Error: no header defined in POT for file
$fnโ cast byheader() - Error: textdomain parameter is required โ cast by
new() - Error: the only acceptable parameter is
'ACTIVE', not'$p'โ cast bytranslations() - Error: there is no Plural-Forms field in the header, but needed โ cast by
pluralIndex() - Error: translation already exists for
'$msgid'with'$ctxtโ cast byadd() - Error: unsupported charset
$charsetin$fnโ cast byread()
yes, that "no filename or file-handle specified for PO" really is listed twice. we keep the facts exactly as they are, periodt ๐
๐ 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.
and that's the whole page, bestie โ perl v5.40.1, dated 2025-11-11, from the Log::R...on::POT(3pm) era ๐ go forth and manage those PO files, you absolute icon ๐โจ
๐ฆ 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