CatalystX::I18N::Role::NumberFormat - Support for I18N number formating
package MyApp::Catalyst; use Catalyst qw/MyPlugins CatalystX::I18N::Role::Base CatalystX::I18N::Role::NumberFormat/; package MyApp::Catalyst::Controller::Main; use strict; use warnings; use parent qw/Catalyst::Controller/; sub action : Local { my ($self,$c) = @_; $c->stash->{total} = $c->i18n_numberformat->format_price(102.34); }
This role add support for localised numbers to your Catalyst application.
All methods are lazy. This means that the values will be only calculated upon the first call of the method.
my $number_format = $c->i18n_numberformat; $number_format->format_price(27.03);
Returns a Number::Format object for your current locale.
The Number::Format settings will be taken from POSIX::localeconv but can be overdriven in your Catalyst I18N configuration:
# Add some I18N configuration __PACKAGE__->config( name => 'MyApp', I18N => { default_locale => 'de_AT', locales => { 'de_AT' => { int_curr_symbol => 'EURO', }, } }, );
Of course fetching the default locale settings via POSIX::localeconv works only if you have the requested locales installed.
The following configuration options are available (see Number::Format for detailed documentation):
int_curr_symbol
currency_symbol
mon_decimal_point
mon_thousands_sep
mon_grouping
positive_sign
negative_sign
int_frac_digits
frac_digits
p_cs_precedes
p_sep_by_space
n_cs_precedes
n_sep_by_space
p_sign_posn
n_sign_posn
thousands_sep
decimal_point
decimal_fill
neg_format
decimal_digits
Number::Format
Maroš Kollár CPAN ID: MAROS maros [at] k-1.com L<http://www.k-1.com>
To install CatalystX::I18N, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::I18N
CPAN shell
perl -MCPAN -e shell install CatalystX::I18N
For more information on module installation, please visit the detailed CPAN module installation guide.