1=encoding utf8
2
3=head1 NAME
4
5Log::Report::Translator - base implementation for translating messages
6
7=head1 INHERITANCE
8
9 Log::Report::Translator is extended by
10   Log::Report::Translator::Gettext
11   Log::Report::Translator::POT
12
13=head1 SYNOPSIS
14
15 # internal infrastructure
16 my $msg = Log::Report::Message->new(_msgid => "Hello World\n");
17 print Log::Report::Translator->new(...)->translate($msg);
18
19 # normal use
20 textdomain 'my-domain'
21   , translator => Log::Report::Translator->new;  # default
22 print __"Hello World\n";
23
24=head1 DESCRIPTION
25
26A module (or distribution) has a certain way of translating messages,
27usually C<gettext>.  The translator is based on some C<textdomain>
28for the message, which can be specified as option per text element,
29but usually is package scoped.
30
31This base class does not translate at all: it will use the MSGID
32(and MSGID_PLURAL if available).  It's a nice fallback if the
33language packs are not installed.
34
35=head1 METHODS
36
37=head2 Constructors
38
39=over 4
40
41=item Log::Report::Translator-E<gt>B<new>(%options)
42
43=back
44
45=head2 Accessors
46
47=head2 Translating
48
49=over 4
50
51=item $obj-E<gt>B<load>($domain, $locale)
52
53Load the translation information in the text $domain for the indicated $locale.
54Multiple calls to L<load()|Log::Report::Translator/"Translating"> should not cost significant performance: the
55data must be cached.
56
57=item $obj-E<gt>B<translate>( $message, [$language, $ctxt] )
58
59Returns the translation of the $message, a C<Log::Report::Message> object,
60based on the current locale.
61
62Translators are permitted to peek into the internal HASH of the
63message object, for performance reasons.
64
65=back
66
67=head1 SEE ALSO
68
69This module is part of Log-Report distribution version 1.33,
70built on July 17, 2021. Website: F<http://perl.overmeer.net/CPAN/>
71
72=head1 LICENSE
73
74Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
75
76This program is free software; you can redistribute it and/or modify it
77under the same terms as Perl itself.
78See F<http://dev.perl.org/licenses/>
79
80