NAME
Log::Report::Lexicon::MOTcompact - use translations from an MO file
INHERITANCE
Log::Report::Lexicon::MOTcompact
is a Log::Report::Lexicon::Table
SYNOPSIS
# using a MO table efficiently
my $mot = Log::Report::Lexicon::MOTcompact->read('mo/nl.mo')
or die;
my $header = $mot->msgid('');
print $mot->msgstr($msgid, 3);
DESCRIPTION
This module is translating, based on MO files (binary versions of the PO files, the "Machine Object" format)
Actually, this module is not "compact" anymore: not trading off speed for memory. That may change again in the future.
To get a MO file, you first need a PO file. Then run msgfmt, which is part of the gnu gettext package.
msgfmt -cv -o $domain.mo $domain.po
# -c = --check-format & --check-header & --check-domain
# -v = --verbose
# -o = --output-file
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)
-
Inherited, see "Constructors" in Log::Report::Lexicon::Table
- $class->read($filename, %options)
-
Read the MOT table information from
$filename
.-Option --Default charset <from header>
Attributes
Extends "Attributes" in Log::Report::Lexicon::Table.
- $obj->filename()
-
Returns the name of the source file for this data.
- $obj->index()
-
Returns a HASH of all defined PO objects, organized by msgid. Please try to avoid using this: use msgid() for lookup.
- $obj->originalCharset()
-
Returns the character-set as found in the PO-file. The strings are converted into utf8 before you use them in the program.
Managing PO's
Extends "Managing PO's" in Log::Report::Lexicon::Table.
Translation
Extends "Translation" in Log::Report::Lexicon::Table.
- $obj->msgid( STRING, [$msgctxt] )
-
Lookup the translations with the
STRING
. Returns a SCALAR, when only one translation is known, and an ARRAY when we have plural forms. Returnsundef
when the translation is not defined. Improves base, see "Translation" in Log::Report::Lexicon::Table - $obj->msgstr( $msgid, [$count, $msgctxt] )
-
Returns the translated string for
$msgid
. When not specified,$count
is 1 (the singular form). Improves base, see "Translation" in Log::Report::Lexicon::Table
Administration
Extends "Administration" in Log::Report::Lexicon::Table.
- $obj->add($po)
-
Inherited, see "Administration" in Log::Report::Lexicon::Table
- $obj->header($field)
-
Inherited, 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] )
-
Inherited, see "Administration" in Log::Report::Lexicon::Table
DIAGNOSTICS
- Error: cannot detect charset in $fn
-
Cast by read()
- Fault: cannot read magic from $fn: $!
-
Cast by read()
- Fault: cannot read mo from file $fn: $!
-
Cast by read()
- Fault: cannot read msgids from $fn, need $size at $loc: $!
-
Cast by read()
- Fault: cannot read originals from $fn, need $size at $loc: $!
-
Cast by read()
- Fault: cannot read superblock from $fn: $!
-
Cast by read()
- Fault: cannot read translations from $fn, need $size at $loc: $!
-
Cast by read()
- Fault: cannot read translations from $fn, need $size at $loc: $!
-
Cast by read()
- Fault: cannot seek to $loc in $fn for msgid strings: $!
-
Cast by read()
- Fault: cannot seek to $loc in $fn for originals: $!
-
Cast by read()
- Fault: cannot seek to $loc in $fn for transl strings: $!
-
Cast by read()
- Fault: cannot seek to $loc in $fn for translations: $!
-
Cast by read()
- Error: invalid plural-form algorithm '$alg'
-
Cast by setupPluralAlgorithm()
- Error: only acceptable parameter is 'ACTIVE'
-
Cast by translations()
- Error: the header is not the first entry, needed for charset in $fn
-
Cast by read()
- Error: there is no Plural-Forms field in the header, but needed
-
Cast by pluralIndex()
- Error: unsupported charset $charset in $fn
-
Cast by read()
- Error: unsupported explicit charset $charset for $fn
-
Cast by read()
- Error: unsupported file type (magic number is $magic)
-
Cast by read()
SEE ALSO
This module is part of Log-Report-Lexicon version 1.14, built on September 08, 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.