Maroš Kollár > CatalystX-I18N > CatalystX::I18N::Role::NumberFormat

Download:
CatalystX-I18N-1.13.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source  

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):

SEE ALSO ^

Number::Format

AUTHOR ^

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