/usr/share/perl5/Log/Report/Translator/POT.pm is in liblog-report-perl 0.998-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # Copyrights 2007-2013 by [Mark Overmeer].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.01.
use warnings;
use strict;
package Log::Report::Translator::POT;
use vars '$VERSION';
$VERSION = '0.998';
use base 'Log::Report::Translator';
use Log::Report 'log-report', syntax => 'SHORT';
use Log::Report::Lexicon::Index;
use Log::Report::Lexicon::POTcompact;
use POSIX qw/:locale_h/;
my %indices;
# Work-around for missing LC_MESSAGES on old Perls and Windows
{ no warnings;
eval "&LC_MESSAGES";
*LC_MESSAGES = sub(){5} if $@;
}
sub translate($;$)
{ my ($self, $msg, $lang) = @_;
my $domain = $msg->{_domain};
my $locale = $lang || setlocale(LC_MESSAGES)
or return $self->SUPER::translate($msg, $lang);
my $pot
= exists $self->{pots}{$domain}{$locale}
? $self->{pots}{$domain}{$locale}
: $self->load($domain, $locale);
defined $pot
or return $self->SUPER::translate($msg, $lang);
$pot->msgstr($msg->{_msgid}, $msg->{_count})
|| $self->SUPER::translate($msg, $lang); # default translation is 'none'
}
sub load($$)
{ my ($self, $domain, $locale) = @_;
foreach my $lex ($self->lexicons)
{ my $fn = $lex->find($domain, $locale);
!$fn && $lex->list($domain)
and last; # there are tables for domain, but not our lang
$fn or next;
my ($ext) = lc($fn) =~ m/\.(\w+)$/;
my $class
= $ext eq 'mo' ? 'Log::Report::Lexicon::MOTcompact'
: $ext eq 'po' ? 'Log::Report::Lexicon::POTcompact'
: error __x"unknown translation table extension '{ext}' in {filename}"
, ext => $ext, filename => $fn;
info __x"read table {filename} as {class} for {domain} in {locale}"
, filename => $fn, class => $class, domain => $domain
, locale => $locale
if $domain ne 'log-report'; # avoid recursion
eval "require $class" or panic $@;
return $self->{pots}{$domain}{$locale}
= $class->read($fn, charset => $self->charset);
}
$self->{pots}{$domain}{$locale} = undef;
}
1;
|