CLDR-Number

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

 - Locales with value `2`: be (Belarusian), bg (Bulgarian), es (Spanish),
   et (Estonian), ka (Georgian), pl (Polish), pt-PT (European Portuguese)
 - Locales with value `3`: lv (Latvian), my (Burmese)

 [ Examples ]
 - en (1): 100 | 1,000 | 10,000 | 100,000 | 1,000,000
 - pl (2): 100 |  1000 | 10 000 | 100 000 | 1 000 000
 - my (3): ၁၀၀ |  ၁၀၀၀ |  ၁၀၀၀၀ | ၁၀၀,၀၀၀ | ၁,၀၀၀,၀၀၀

0.15 2015-09-22
 - Bugfix: fix support for formatting `Inf` and `NaN` in Perl v5.22, which has
   changed from the previous values `inf` and `nan` [#46]

0.14 2015-09-21
 - Bugfix: fix formatting negative numbers along with a custom
   rounding_increment value, which had caused double negative signs
 - Bugfix: fix formatting of string values `inf` and `nan` which weren’t treated
   as numeric on combinations of some operating systems with some older versions
   of Perl [#44, #45]
 - Docs: typo fix by Fred Moyer @redhotpenguin++ [#43]

Changes  view on Meta::CPAN

 - osma (Osmanya Digits)
 - shrd (Sharada Digits)
 - sind (Khudawadi Digits)
 - sinh (Sinhala Lith Digits)
 - sora (Sora Sompeng Digits)
 - takr (Takri Digits)
 - tirh (Tirhuta Digits)
 - wara (Warang Citi Digits)

0.12 2015-08-29
 - Add support for passing infinity, negative infinity, and NaN arguments to all
   formatting methods (format, at_least, range) on all formatting classes
   (decimal, percent, currency), because those are valid numeric values in Perl,
   which are now all localized even though it doesn’t always make
   sense [issue #26]
 - Add `infinity` and `nan` attributes to all classes in addition to the decimal
   formatter

0.11 2015-08-25
 - Upgrade CLDR data from v24 (2013-09-18) to v27.0.1 (2015-03-30) [issue #33]
 - Add bin/generate-cldr-data.pl script to update Perl data from CLDR JSON

README  view on Meta::CPAN


    plus_sign
        Examples: "+" (plus sign) for root, en, and most locales

    minus_sign
        Examples: "-" (hyphen-minus) for root, en, and most locales

    infinity
        Examples: "∞" (infinity) for root, en, and almost all locales

    nan Examples: "NaN" for root, en, and most locales; many other
        variations for individual locales like "не число" for ru and "非數值"
        for zh-Hant

    cldr_version
        Value: 29

        This is a read-only attribute that will always reflect the currently
        supported Unicode CLDR version.

NOTES

lib/CLDR/Number.pm  view on Meta::CPAN

=item minus_sign

Examples: C<-> (hyphen-minus) for B<root>, B<en>, and most locales

=item infinity

Examples: C<∞> (infinity) for B<root>, B<en>, and almost all locales

=item nan

Examples: C<NaN> for B<root>, B<en>, and most locales; many other variations for
individual locales like C<не число> for B<ru> and C<非數值> for B<zh-Hant>

=item cldr_version

Value: C<29>

This is a read-only attribute that will always reflect the currently supported
Unicode CLDR version.

=back

lib/CLDR/Number/Data/Base.pm  view on Meta::CPAN

            currency => '¤ #,##0.00',
            decimal => '#,##0.###',
            percent => '#,##0%',
            range => '{0}–{1}',
        },
        symbol => {
            decimal => '.',
            group => ',',
            infinity => '∞',
            minus => '-',
            nan => 'NaN',
            percent => '%',
            permil => '‰',
            plus => '+',
        },
        attr => {
            min_group => 1,
            system => 'latn',
        },
    },
    af => {

lib/CLDR/Number/Format/Decimal.pm  view on Meta::CPAN

to submit comments or concerns.

=head1 DESCRIPTION

Localized decimal formatter using the Unicode Common Locale Data Repository
(CLDR).

=head2 Methods

Any argument that Perl can treat as a number is supported, including infinity,
negative infinity, and NaN, which are all localized appropriately. All methods
return character strings, not encoded byte strings.

=over

=item format

Accepts a number and returns a formatted decimal, localized for the current
locale.

=item at_least

t/inf-nan.t  view on Meta::CPAN

my $inf = 9**9**9;
my $neg = -$inf;
my $nan = -sin($inf);

my $cldr = CLDR::Number->new(locale => 'en');
my $decf = $cldr->decimal_formatter;
my $perf = $cldr->percent_formatter;
my $curf = $cldr->currency_formatter(currency_code => 'EUR');

is $cldr->infinity, '∞',   'infinity attribute';
is $cldr->nan,      'NaN', 'nan attribute';

is $decf->format($inf), '∞',   'format infinity';
is $decf->format($neg), '-∞',  'format negative infinity';
is $decf->format($nan), 'NaN', 'format NaN';

SKIP: {
    skip 'infinity and NaN strings not supported on this system', 6
        if 'inf' != $inf;

    is $decf->format('inf'),  '∞',   'format lowercase "inf" string';
    is $decf->format('-inf'), '-∞',  'format lowercase "-inf" string';
    is $decf->format('nan'),  'NaN', 'format lowercase "nan" string';

    is $decf->format('Inf'),  '∞',   'format titlecase "Inf" string';
    is $decf->format('-Inf'), '-∞',  'format titlecase "-Inf" string';
    is $decf->format('NaN'),  'NaN', 'format titlecase "NaN" string';
}

is $perf->format($inf), '∞%',   'format infinity percent';
is $perf->format($neg), '-∞%',  'format negative infinity percent';
is $perf->format($nan), 'NaN%', 'format NaN percent';

is $curf->format($inf), '€∞',   'format infinity euros';
is $curf->format($neg), '-€∞',  'format negative infinity euros';
is $curf->format($nan), '€NaN', 'format NaN euros';

is $decf->at_least($inf), '∞+',   'format at least infinity';
is $decf->at_least($nan), 'NaN+', 'format at least NaN';

is $decf->range($neg, $inf), '-∞–∞',    'format range of infinity';
is $decf->range($nan, $nan), 'NaN–NaN', 'format range of NaN';

$cldr = CLDR::Number->new(locale => 'dz');
$decf = $cldr->decimal_formatter;
$perf = $cldr->percent_formatter;
$curf = $cldr->currency_formatter(currency_code => 'BTN');

is $cldr->infinity, 'གྲངས་མེད', 'infinity attribute (dz)';
is $cldr->nan,      'ཨང་མད',  'nan attribute (dz)';

is $decf->format($inf), 'གྲངས་མེད',  'format infinity (dz)';
is $decf->format($neg), '-གྲངས་མེད', 'format negative infinity (dz)';
is $decf->format($nan), 'ཨང་མད',   'format NaN (dz)';

is $perf->format($inf), 'གྲངས་མེད %',  'format infinity percent (dz)';
is $curf->format($inf), 'Nu.གྲངས་མེད', 'format infinity ngultrums (dz)';



( run in 0.299 second using v1.01-cache-2.11-cpan-4d50c553e7e )