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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
=encoding utf8
=head1 NAME
Log::Report::Translator::POT - translation based on POT files
=head1 INHERITANCE
Log::Report::Translator::POT
is a Log::Report::Translator
=head1 SYNOPSIS
# internal use
my $msg = Log::Report::Message->new(
_msgid => "Hello World\n",
_domain => 'my-domain',
);
print Log::Report::Translator::POT
->new(lexicons => $dir)
->translate($msg, 'nl-BE');
# normal use (end-users view in the program's ::main)
textdomain 'my-domain',
translator => Log::Report::Translator::POT->new(lexicon => $dir);
print __"Hello World\n";
=head1 DESCRIPTION
Translate a message by directly accessing POT files. The files will load
lazily (unless forced). This module accesses the PO's in a compact way,
using L<Log::Report::Lexicon::POTcompact|Log::Report::Lexicon::POTcompact>, which is much more efficient
than L<Log::Report::Lexicon::PO|Log::Report::Lexicon::PO>.
=head1 METHODS
=head2 Constructors
=over 4
=item $class-E<gt>B<new>(%options)
Z<>
-Option --Default
charset <C<undef>>
lexicons <see text>
=over 2
=item charset => STRING
Enforce character set for files. We default to reading the character-set
as defined in the header of each PO file.
=item lexicons => DIRECTORY
The DIRECTORY where the translations can be found. See
L<Log::Report::Lexicon::Index|Log::Report::Lexicon::Index> for the expected structure of such
DIRECTORY.
The default is based on the location of the module which instantiates
this translator. The filename of the module is stripped from its C<.pm>
extension, and used as directory name. Within that directory, there
must be a directory named C<messages>, which will be the root directory
of a L<Log::Report::Lexicon::Index|Log::Report::Lexicon::Index>.
=back
example: default lexicon directory
# file xxx/perl5.8.8/My/Module.pm
use Log::Report 'my-domain',
translator => Log::Report::Translator::POT->new;
# lexicon now in xxx/perl5.8.8/My/Module/messages/
=back
=head2 Accessors
=over 4
=item $obj-E<gt>B<charset>()
Returns the default charset, which can be overrule by the locale.
=item $obj-E<gt>B<lexicons>()
Returns a list of L<Log::Report::Lexicon::Index|Log::Report::Lexicon::Index> objects, where the
translation files may be located.
=back
=head2 Translating
=over 4
=item $obj-E<gt>B<translate>($msg, $lang, $context)
Z<>
=back
=head1 DIAGNOSTICS
=over 4
=item Error: You have to upgrade Log::Report::Lexicon to at least 1.00
Cast by new()
=item Info: read table $filename as $class for $dname in $locale
Cast by translate()
=item Error: unknown translation table extension '$ext' in $filename
Cast by translate()
=back
=head1 SEE ALSO
This module is part of Log-Report-Lexicon version 1.14,
built on September 08, 2025. Website: F<http://perl.overmeer.net/CPAN/>
=head1 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.
|