Log-Report-Lexicon
view release on metacpan or search on metacpan
lib/Log/Report/Lexicon/MOTcompact.pm view on Meta::CPAN
my $msgid_b = substr $orig_block, $id_loc-$orig_start, $id_len;
my $msgctxt_b = $msgid_b =~ s/(.*)\x04// ? $1 : '';
my ($trans_len, $trans_loc) = (shift @trans, shift @trans);
my $msgstr_b = substr $trans_block, $trans_loc - $trans_start, $trans_len;
unless(defined $charset)
{ $msgid_b eq ''
or error __x"the header is not the first entry, needed for charset in {fn}", fn => $fn;
$charset = $msgstr_b =~ m/^content-type:.*?charset=["']?([\w-]+)/mi ? $1
: error __x"cannot detect charset in {fn}", fn => $fn;
trace "auto-detected charset $charset for $fn";
$enc = find_encoding($charset)
or error __x"unsupported charset {charset} in {fn}", charset => $charset, fn => $fn;
}
my $msgid = $enc->decode($msgid_b);
my $msgctxt = $enc->decode($msgctxt_b);
lib/Log/Report/Lexicon/POT.pm view on Meta::CPAN
{ my $location = "$fn line $linenr";
my $block = <$fh>;
defined $block or last;
$linenr += $block =~ tr/\n//;
$block =~ s/\s+\z//s;
length $block or last;
unless($charset)
{ $charset = $block =~ m/\"content-type:.*?charset=["']?([\w-]+)/mi ? $1
: error __x"cannot detect charset in {fn}", fn => $fn;
trace "auto-detected charset $charset for $fn";
binmode $fh, ":encoding($charset):crlf";
$block = decode $charset, $block
or error __x"unsupported charset {charset} in {fn}", charset => $charset, fn => $fn;
}
my $po = Log::Report::Lexicon::PO->fromText($block, $location);
lib/Log/Report/Lexicon/POTcompact.pm view on Meta::CPAN
# Speed!
my $msgctxt = '';
my ($last, $msgid, @msgstr);
my $index = $self->{index} ||= {};
my $add = sub {
unless($charset)
{ $msgid eq ''
or error __x"header not found for charset in {fn}", fn => $fn;
$charset = $msgstr[0] =~ m/^content-type:.*?charset=["']?([\w-]+)/mi ? $1
: error __x"cannot detect charset in {fn}", fn => $fn;
my $enc = find_encoding($charset)
or error __x"unsupported charset {charset} in {fn}", charset => $charset, fn => $fn;
trace "auto-detected charset $charset for $fn";
binmode $fh, ":encoding($charset):crlf";
$_ = $enc->decode($_) for @msgstr, $msgctxt;
}
lib/Log/Report/Lexicon/POTcompact.pod view on Meta::CPAN
Comments, plural-form, and such are lost on purpose: they are not
needed for translations.
-Option --Default
charset undef
=over 2
=item charset => STRING
When the charset is not specified, it will be taken from the content-type
field in the po-file header.
=back
=back
=head2 Attributes
Extends L<"Attributes" in Log::Report::Lexicon::Table|Log::Report::Lexicon::Table/"Attributes">.
( run in 1.180 second using v1.01-cache-2.11-cpan-524268b4103 )