NAME
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 $
VERSION
1.02
SYNOPSIS
DESCRIPTION
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.
SUBROUTINES/METHODS
class method set_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';
},
);
class method get_escape
Get back the current escape code reference for extra escape.
$code_ref
= HTML::Template::Compiled::Plugin::I18N::DefaultTranslator->get_escape();
class method translate
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.
DIAGNOSTICS
none
CONFIGURATION AND ENVIRONMENT
none
DEPENDENCIES
Carp
INCOMPATIBILITIES
The output is not readable by a parser but very good human readable during the application development.
BUGS AND LIMITATIONS
not known
AUTHOR
Steffen Winkler
LICENSE AND COPYRIGHT
Copyright (c) 2009, Steffen Winkler <steffenw at cpan.org>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.