Mojolicious::Plugin::TagHelpersI18N - TagHelpers with I18N support
version 0.05
use Mojolicious::Lite; plugin('I18N' => { namespace => 'Local::I18N', default => 'de' } ); plugin('TagHelpersI18N'); any '/' => sub { my $self = shift; $self->render( 'default' ); }; any '/no' => sub { shift->render }; app->start; __DATA__ @@ default.html.ep %= select_field 'test' => [qw/hello test/]; @@ no.html.ep %= select_field 'test' => [qw/hello test/], no_translation => 1
The TagHelpers in Mojolicious::Plugin::TagHelpers are really nice. Unfortunately, I need to create select fields where the labels are translated.
select
This plugin is the solution for that.
Additionally to the stock select_field helper, you can pass the option no_translation to avoid translated values
select_field
%= select_field test => [qw(hello one)];
results in
<select name="test"><option value="hello">Hallo</option><option value="one">eins</option></select>
and
%= select_field test => [qw(hello one)], no_translation => 1;
<select name="test"><option value="hello">hello</option><option value="one">one</option></select>
in de.pm:
'hello' => 'Hallo', 'one' => 'eins',
With this module you can sort the options:
%= select_field test => [qw/one hello/], sort => 1;
With translation enabled, the translated labels are sorted.
More info about select_field: Mojolicious::Plugin::TagHelpers
Renee Baecker <reneeb@cpan.org>
This software is Copyright (c) 2014 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Mojolicious::Plugin::TagHelpersI18N, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::TagHelpersI18N
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::TagHelpersI18N
For more information on module installation, please visit the detailed CPAN module installation guide.