METHODS

Constructors

$obj->clone( OPTIONS, VARIABLES )

Returns a new object which copies info from original, and updates it with the specified OPTIONS and VARIABLES. The advantage is that the cached translations are shared between the objects.

» Example: use of clone()
 my $s = __x "found {nr} files", nr => 5;
 my $t = $s->clone(nr => 3);
 my $t = $s->(nr => 3);      # equivalent
 print $s;     # found 5 files
 print $t;     # found 3 files
$class->new( OPTIONS, VARIABLES )
Option Default

_append

undef

_category

undef

_class

[]

_classes

[]

_count

undef

_domain

from use

_expand

false

_msgid

undef

_plural

undef

_prepend

undef

_append => STRING
_category => INTEGER
_class => STRING|ARRAY
When messages are used for exception based programming, you add _class parameters to the argument list. Later, with for instance Log::Report::Dispatcher::Try::wasFatal(class), you can check the category of the message.
One message can be part of multiple classes. The STRING is used as comma- and/or blank seperated list of class tokens, the ARRAY lists all tokens seperately.
_classes => STRING|ARRAY
Alternative for _class, which cannot be used at the same time.
_count => INTEGER
When defined, then _plural need to be defined as well.
_domain => STRING
The textdomain in which this msgid is defined.
_expand => BOOLEAN
Indicates whether variables are filled-in.
_msgid => MSGID
The message label, which refers to some translation information. Usually a string which is close the English version of the error message. This will also be used if there is no translation possible
_plural => MSGID
Can be specified when a _count is specified. This plural form of the message is used to simplify translation, and as fallback when no translations are possible: therefore, this can best resemble an English message.
_prepend => STRING

Accessors

$obj->append

Returns the string or Log::Report::Message object which is appended after this one. Usually undef.

$obj->classes

Returns the LIST of classes which are defined for this message; message group indicators, as often found in exception-based programming.

$obj->count

Returns the count, which is used to select the translation alternatives.

$obj->domain

Returns the domain of the first translatable string in the structure.

$obj->msgid

Returns the msgid which will later be translated.

$obj->prepend

Returns the string which is prepended to this one. Usually undef.

$obj->valueOf( PARAMETER )

Lookup the named PARAMETER for the message. All pre-defined names have their own method, and should be used with preference.

» Example:

When the message was produced with

  my @files = qw/one two three/;
  my $msg = __xn "found one file: {files}"
               , "found {_count} files: {files}"
               , scalar @files, files => \@files
               , _class => 'IO, files';

then the values can be takes from the produced message as

  my $files = $msg->valueOf('files');  # returns ARRAY reference
  print @$files;              # 3
  my $count = $msg->count;    # 3
  my @class = $msg->classes;  # 'IO', 'files'
  if($msg->inClass('files'))  # true

Processing

$obj->concat( STRING|OBJECT, [PREPEND] )

This method implements the overloading of concatenation, which is needed to delay translations even longer. When PREPEND is true, the STRING or OBJECT (other Log::Report::Message) needs to prepended, otherwise it is appended.

» Example: of concatenation
 print __"Hello" . ' ' . __"World!";
 print __("Hello")->concat(' ')->concat(__"World!")->concat("\n");
$obj->inClass( CLASS|REGEX )

Returns true if the message is in the specified CLASS (string) or matches the REGEX. The trueth value is the (first matching) class.

$obj->toString( [LOCALE] )

Translate a message. If not specified, the default locale is used.

$obj->untranslated

Return the concatenation of the prepend, msgid, and append strings. Variable expansions within the msgid is not performed.