Log::Report::Translator3pm
Base implementation for translating messages
Usage
# internal infrastructuremy $msg = Log::Report::Message->new(_msgid => "Hello World\n");print Log::Report::Translator->new(...)->translate($msg);# normal usetextdomain 'my-domain',translator => Log::Report::Translator->new; # defaultprint __"Hello World\n";
Inheritance
Log::Report::Translator is extended byLog::Report::Translator::GettextLog::Report::Translator::POT
Overview
A module (or distribution) has a certain way of translating messages, usually "gettext". The translator is based on some "textdomain" for the message, which can be specified as option per text element, but usually is package scoped.
This base class does not translate at all: it will use the MSGID (and MSGID_PLURAL if available). It's a nice fallback if the language packs are not installed.
Methods
Constructors
- $class->
new(%options)
Attributes
Translating
- $obj->
load($domain, $locale) -
Load the translation information in the text
$domainfor the indicated$locale. Multiple calls toload()should not cost significant performance: the data must be cached.
- $obj->
translate( $message, [$language, $ctxt] ) -
Returns the translation of the
$message, a Log::Report::Message object, based on the current locale.Translators are permitted to peek into the internal HASH of the message object, for performance reasons.
Releases
8 releases since Debian 7 (Wheezy); the text changed 7 times.