CLDR::Number::Format::Decimal - Localized decimal formatter using the Unicode CLDR
This document describes CLDR::Number::Format::Decimal v0.11, built with Unicode CLDR v27.0.1.
# either use CLDR::Number::Format::Decimal; $decf = CLDR::Number::Format::Decimal->new(locale => 'es'); # or use CLDR::Number; $cldr = CLDR::Number->new(locale => 'es'); $decf = $cldr->decimal_formatter; # when locale is 'es' (Spanish) say $decf->format(1234.5); # '1.234,5' # when locale is 'es-MX' (Mexican Spanish) say $decf->format(1234.5); # '1,234.5' # when locale is 'ar' (Arabic) say $decf->format(1234.5); # '١٬٢٣٤٫٥' # when locale is 'bn' (Bengali) say $curf->format(123456); # '১,২৩,৪৫৬'
Using the locale method as a setter is deprecated. In the future the object’s locale will become immutable. Please see issue #38 for details and to submit comments or concerns.
locale
Localized decimal formatter using the Unicode Common Locale Data Repository (CLDR).
All methods return character strings, not encoded byte strings.
Accepts a number and returns a formatted decimal, localized for the current locale.
Accepts a number and returns a formatted decimal for at least the supplied number.
say $decf->at_least(100); # '100+'
Accepts two numbers and returns a formatted range of decimals.
say $decf->range(1, 10); # '1–10'
The common attributes locale, default_locale, numbering_system, decimal_sign, group_sign, plus_sign, minus_sign, and cldr_version are described under common attributes in CLDR::Number. All attributes described here have defaults that change depending on the current locale. All string attributes are expected to be character strings, not byte strings.
Examples: #,##0.### for root, en, and most locales; #,##,##0.### for hi, bn, en-IN, and other locales of the Indian subcontinent
#,##0.###
#,##,##0.###
Examples: 1 for all locales
1
Examples: 0 for all locales
0
Examples: 3 for root and almost all locales
3
Not used when value is 0.
Examples: 0 for root, en, and most locales; 2 for hi, bn, en-IN, and other locales of the Indian subcontinent
2
0 and 1 are treated the same.
Examples: ∞ (infinity) for root, en, and almost all locales
∞
Examples: NaN for root, en, and most locales; many other variations for individual locales like не число for ru and 非數值 for zh-Hant
NaN
не число
非數值
CLDR::Number
Nova Patch <patch@cpan.org>
This project is brought to you by Shutterstock. Additional open source projects from Shutterstock can be found at code.shutterstock.com.
© 2013–2015 Shutterstock, Inc.
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.