The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CatalystX::I18N::Role::NumberFormat - Support for I18N number formating

SYNOPSIS

 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);
 }

DESCRIPTION

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.

METHODS

i18n_numberformat

 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

SEE ALSO

Number::Format

AUTHOR

    Maroš Kollár
    CPAN ID: MAROS
    maros [at] k-1.com
    
    L<http://www.k-1.com>