Any use of a translation function exported by Log::Report, like __() (the function is named underscore-underscore) or __x() (underscore-underscore-x) will result in this object. It will capture some environmental information, and delay the translation until it is needed.

Creating an object first and translating it later, is slower than translating it immediately. However, on the location where the message is produced, we do not yet know in what language to translate it to: that depends on the front-end, the log dispatcher.

End-users: do not use this method directly, but use Log::Report::__() and friends. The %options is a mixed list of object initiation parameters (all with a leading underscore) and variables to be filled in into the translated _msgid string.

With this parameter, your can "borrow" translations from other textdomains. Be very careful with this (although there are good use-cases) The xgettext msgid extractor may add the used msgid to this namespace as well. To avoid that, add a harmless '+':

print __x(+"errors", _domain => 'global');

The extractor will not take the msgid when it is an expression. The '+' has no effect on the string at runtime.

Can be used together with _count. This plural form of the _msgid text is used to simplify the work of translators, and as fallback when no translation is possible: therefore, this can best resemble an English message.

White-space at the beginning and end of the string are stripped off. The white-space provided by the _msgid will be used.

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.

The Log::Report functions which define translation request can all have OPTIONS. Some can have VARIABLES to be interpolated in the string as well. To distinguish between the OPTIONS and VARIABLES (both a list of key-value pairs), the keys of the OPTIONS start with an underscore _. As result of this, please avoid the use of keys which start with an underscore in variable names. On the other hand, you are allowed to interpolate OPTION values in your strings.

With the __x() or __nx(), interpolation will take place on the translated MSGID string. The translation can contain the VARIABLE and OPTION names between curly brackets. Text between curly brackets which is not a known parameter will be left untouched.

(1) this required third parameter is used to switch between the different plural forms. English has only two forms, but some languages have many more.

(2) the "scalar" keyword is not needed, because the third parameter is in SCALAR context. You may also pass \@files there, because ARRAYs will be converted into their length. A HASH will be converted into the number of keys in the HASH.

(3) the scalar keyword is required here, because it is LIST context: otherwise all filenames will be filled-in as parameters to __xn(). See below for the available _count valure, to see how the nr_files parameter can disappear.

Log::Report uses String::Print to interpolate values in(translated) messages. This is a very powerful syntax, and you should certainly read that manual-page. Here, we only described additional features, specific to the usage of String::Print in Log::Report::Message objects.

There is no way of checking beforehand whether you have provided all required values, to be interpolated in the translated string.

For interpolating, the following rules apply:

Simple scalar values are interpolated "as is"

References to SCALARs will collect the value on the moment that the output is made. The Log::Report::Message object which is created with the __xn can be seen as a closure. The translation can be reused. See example below.

Code references can be used to create the data "under fly". The Log::Report::Message object which is being handled is passed as only argument. This is a hash in which all OPTIONS and VARIABLES can be found.

When the value is an ARRAY, all members will be interpolated with $" between the elements. Alternatively (maybe nicer), you can pass an interpolation parameter via the _join OPTION.

In above examples, the msgid and plural form have a trailing new-line. In general, it is much easier to write

print __x"Hello, World!\n";

than

print __x("Hello, World!") . "\n";

For the translation tables, however, that trailing new-line is "over information"; it is an layout issue, not a translation issue.

Therefore, the first form will automatically be translated into the second. All leading and trailing white-space (blanks, new-lines, tabs, ...) are removed from the msgid befor the look-up, and then added to the translated string.

Leading and trailing white-space on the plural form will also be removed. However, after translation the spacing of the msgid will be used.