CLDR::Number - Localized number formatters using the Unicode CLDR
This document describes CLDR::Number v0.00_03, built with Unicode CLDR v24. This is a development release without full documentation and functionality may change. See CLDR::Number::TODO.
use CLDR::Number; my $cldr = CLDR::Number->new(locale => 'es'); # decimals my $decf = $cldr->decimal_formatter; say $decf->format(1234.5); # '1 234,5' (Spanish) $decf->locale('es-MX'); say $decf->format(1234.5); # '1,234.5' (Mexican Spanish) # percents my $perf = $cldr->percent_formatter(locale => 'tr'); say $perf->format(0.05); # '%5' (Turkish) # currencies my $curf = $cldr->currency_formatter( locale => 'en', currency_code => 'USD', ); say $curf->format(9.99); # '$9.99' (English / USD) $curf->locale('en-CA'); say $curf->format(9.99); # 'US$9.99' (Canadian English / USD) $curf->locale('fr-CA'); say $curf->format(9.99); # '9,99 $US' (Canadian French / USD)
Returns a decimal formatter, which is a CLDR::Number::Format::Decimal object instantiated with all of the attributes from your CLDR::Number object as well as any attributes passed to this method.
Returns a percent formatter, which is a CLDR::Number::Format::Percent object instantiated with all of the attributes from your CLDR::Number object as well as any attributes passed to this method.
Returns a currency formatter, which is a CLDR::Number::Format::Currency object instantiated with all of the attributes from your CLDR::Number object as well as any attributes passed to this method.
Common attributes among all formatter objects.
Default: value of default_locale attribute if exists, otherwise root
default_locale
root
Valid: Unicode locale identifier
Default: none
Default: . when root locale
.
Default: , when root locale
,
Default: + when root locale
+
Default: - when root locale
-
Value: 24
24
UTS #35: Unicode LDML, Part 3: Numbers
CLDR Translation Guidelines: Number Patterns
CLDR Translation Guidelines: Number Symbols
Nick Patch <patch@cpan.org>
This project is brought to you by Perl CLDR and Shutterstock. Additional open source projects from Shutterstock can be found at code.shutterstock.com.
© 2013 Nick Patch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install CLDR::Number, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CLDR::Number
CPAN shell
perl -MCPAN -e shell install CLDR::Number
For more information on module installation, please visit the detailed CPAN module installation guide.