NAME

CLDR::Number::Format::Decimal - Localized decimal formatter using the Unicode CLDR

VERSION

This document describes CLDR::Number::Format::Decimal v0.07, built with Unicode CLDR v24.

SYNOPSIS

# either
use CLDR::Number::Format::Decimal;
my $decf = CLDR::Number::Format::Decimal->new(locale => 'es');

# or
use CLDR::Number;
my $cldr = CLDR::Number->new(locale => 'es');
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)

$decf->locale('ar');
say $decf->format(1234.5);  # '١٬٢٣٤٫٥' (Arabic)

$curf->locale('bn');
say $curf->format(123456);  # '১,২৩,৪৫৬' (Bengali)

DESCRIPTION

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

Methods

All methods return character strings, not encoded byte strings.

format

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

at_least

Accepts a number and returns a formatted decimal for at least the supplied number.

say $decf->at_least(100);  # '100+'
range

Accepts two numbers and returns a formatted range of decimals.

say $decf->range(1, 10);  # '1–10'

Attributes

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.

pattern

Examples: #,##0.### for root, en, and most locales; #,##,##0.### for hi, bn, en-IN, and other locales of the Indian subcontinent

minimum_integer_digits

Examples: 1 for all locales

minimum_fraction_digits

Examples: 0 for all locales

maximum_fraction_digits

Examples: 3 for root and almost all locales

primary_grouping_size

Examples: 3 for root and almost all locales

Not used when value is 0.

secondary_grouping_size

Examples: 0 for root, en, and most locales; 2 for hi, bn, en-IN, and other locales of the Indian subcontinent

Not used when value is 0.

rounding_increment

Examples: 0 for all locales

0 and 1 are treated the same.

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

SEE ALSO

CLDR::Number

AUTHOR

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.

COPYRIGHT AND LICENSE

© 2013–2014 Shutterstock, Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.