Locale::MakePhrase::Print - Overload of print to automate translations
print
Using this module, it will override print statements so that your application automatically gets translated into the target language.
Example:
Your application will have previously instantiated a Locale::MakePhrase object in some other module. Now you need to use that instantiation within a particular module; from here:
use Locale::MakePhrase::Print; ... print "Some text to be translated.";
When print is called, the text is automatically fed into the translation engine.
The purpose of this module, is to de-couple the use of the translation engine, from the API of the translation engine. This saves you from littering your application code with translation-specific function calls. The main benefits are:
makes the code easier to read
allows you to easily change to a different translation engine
decouples translation from application design
To use this module, you simply need to use it at the top of your own module. You can optionally specify a specific filehandle to print to (rather than STDOUT), eg:
use
use Locale::MakePhrase::Print; ... print "Some text";
or
open(FH,">some_output_file.txt") or die; use Locale::MakePhrase::Print \*FH; ... print "Some text";
Will print Some text to STDOUT or the specified filehandle.
To stop overriding print:
no Locale::MakePhrase::Print;
This function is explicatly exported so that users can avoid having to specify the newline character in the translation key.
Note: when no Locale::MakePhrase::Print is in effect, println simply prints out the un-translated string, including a the newline.
no Locale::MakePhrase::Print
println
This module overrides print only for the STDOUT filehandle; this also applies to exported the println function. ie: specifying a filehandle to print will result in no translation occurring, or some weired error if used with println.
Thus to specifically avoid using the overridden print function, explicatly specify the filehandle as in:
print STDOUT "Some un-translated text.";
To install Locale::MakePhrase, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::MakePhrase
CPAN shell
perl -MCPAN -e shell install Locale::MakePhrase
For more information on module installation, please visit the detailed CPAN module installation guide.