NAME
Mojolicious::Plugin::I18NUtils - provide some helper functions for I18N
VERSION
version 0.13
SYNOPSIS
In your startup
:
sub startup {
my $self = shift;
# do some Mojolicious stuff
$self->plugin( 'I18NUtils' );
# more Mojolicious stuff
}
In your template:
<%= datetime_loc('2014-12-10', 'de') %>
CONFIGURE
If you use a default format other than %Y-%m-%d %H:%M:%S for dates in your application, you can set a format for the parser. E.g. if your dates look like
10.12.2014 12:34:56
You can add the plugin this way
$self->plugin( I18NUtils => { format => '%d.%m.%Y %H:%M:%S' } );
HELPERS
This plugin adds two helper methods to your web application:
datetime_loc
This helper returns the givent date and time in the localized format.
<%= datetime_loc('2014-12-10 11:12:13', 'de') %>
will return
10.12.2014 11:12:13
date_loc
Same as datetime_loc
, but omits the time
<%= date_loc('2014-12-10 11:12:13', 'de') %>
will return
10.12.2014
currency
If you need to handle prices, the helper currency
might help you
<%= currency(1111.99, 'EUR', 'ar') %>
<%= currency(1111.99, 'EUR', 'de') %>
<%= currency(1111.99, 'EUR', 'en') %>
will return
€ ١٬١١١٫٩٩
1.111,99 €
€1,111.99
decimal
<%= decimal( 2000, 'ar' ) %>
<%= decimal( 2000, 'de' ) %>
<%= decimal( 2000, 'en' ) %>
will return
٢٬٠٠٠
2.000
2,000
range
<%= range(1, 2000, 'ar' ) %>
<%= range(1, 2000, 'de' ) %>
<%= range(1, 2000, 'en' ) %>
will return
١–٢٬٠٠٠
1–2.000
1–2,000
at_least
<%= at_least( 2000, 'ar' ) %>
<%= at_least( 2000, 'de' ) %>
<%= at_least( 2000, 'en' ) %>
will return
٢٬٠٠٠
2.000
2,000
METHODS
register
Called when registering the plugin.
# load plugin, alerts are dismissable by default
$self->plugin( 'I18NUtils' );
AUTHOR
Renee Baecker <reneeb@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)