HTML::Template::Compiled::Plugin::I18N::DefaultTranslator - an extremly simple translater class for the HTC plugin I18N
$Id: DefaultTranslator.pm 161 2009-12-03 09:05:54Z steffenw $
$HeadURL: https://htc-plugin-i18n.svn.sourceforge.net/svnroot/htc-plugin-i18n/trunk/lib/HTML/Template/Compiled/Plugin/I18N/DefaultTranslator.pm $
1.02
This module is very useful to run the application before the real translator module has been finished.
The I18N plugin calls the class method translate of the translator class. The given parameter is a hash reference of scalars, array or hash references. The translator has to run the given escape code reference for all values. To see the struct of the rest of this hash reference the default translator simplifies to
scalar=value;array=value1,value2;hash=key1,value1
Then the output is human readable.
There is only a simple problem with undefs. Therefore the default translator has an extra escape.
Set an escape code reference to run an extra escape for all the values. The example describes the default to have no undefined values in the maketext array reference or in the gettext hash.
HTML::Template::Compiled::Plugin::I18N::DefaultTranslator->set_escape( sub { my $string = shift; defined $string and return $string; return 'undef'; }, );
Get back the current escape code reference for extra escape.
$code_ref = HTML::Template::Compiled::Plugin::I18N::DefaultTranslator->get_escape();
Possible hash keys are
context (optional string) text (string) plural (optional string) count (optional unsigned integer) maketext (optional array reference) gettext (optional hash reference) formatter (optional array reference) escape (optional code reference)
The scalar values are defined or the hash key does not exists. The array and hash references are references or the hash key does not exists.
$string = HTML::Template::Compiled::Plugin::I18N::DefaultTranslator->translate({ text => 'text', ... });
After a translation text and plural have to escape.
none
Carp
The output is not readable by a parser but very good human readable during the application development.
not known
Steffen Winkler
Copyright (c) 2009, Steffen Winkler <steffenw at cpan.org>. All rights reserved.
<steffenw at cpan.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTML::Template::Compiled::Plugin::I18N, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Template::Compiled::Plugin::I18N
CPAN shell
perl -MCPAN -e shell install HTML::Template::Compiled::Plugin::I18N
For more information on module installation, please visit the detailed CPAN module installation guide.