Amon2-Plugin-L10N
view release on metacpan or search on metacpan
__PACKAGE__->load_plugins('L10N' => {
default_lang => 'en', # default is en
accept_langs => [qw/ en ja zh-tw zh-cn fr /], # default is ['en']
po_dir => 'po', # default is po
});
in your YourProj::Web::ViewFunction
use Text::Xslate ();
sub l {
my $string = shift;
my @args = map { Text::Xslate::html_escape($_) } @_; # escape arguments
Text::Xslate::mark_raw( YourProj->context->loc($string, @args) );
}
in your tmpl/foo.tt
[% l('Hello! %1', 'username') %]
in your some class
package YourProj::M::Foo;
sub bar {
lib/Amon2/Plugin/L10N.pm view on Meta::CPAN
default_lang => 'en', # default is en
accept_langs => [qw/ en ja zh-tw zh-cn fr /], # default is ['en']
po_dir => 'po', # default is po
});
=head2 in your YourProj::Web::ViewFunction
use Text::Xslate ();
sub l {
my $string = shift;
my @args = map { Text::Xslate::html_escape($_) } @_; # escape arguments
Text::Xslate::mark_raw( YourProj->context->loc($string, @args) );
}
=head2 in your tmpl/foo.tt
[% l('Hello! %1', 'username') %]
=head2 in your some class
package YourProj::M::Foo;
( run in 0.417 second using v1.01-cache-2.11-cpan-c21f80fb71c )