CLDR-Number

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

 - 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
 - Add new locales including dsb (Lower Sorbian), fy (West Frisian),
   hsb (Upper Sorbian), lb (Luxembourgish), qu (Quechua), smn (Inari Sami),

README  view on Meta::CPAN


        # when locale is 'es' (Spanish)
        say $decf->format(1234.5);  # '1234,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);  # '١٬٢٣٤٫٥'

        # percents
        $perf = $cldr->percent_formatter;

        # when locale is 'tr' (Turkish)
        say $perf->format(0.05);  # '%5'

        # currencies
        $curf = $cldr->currency_formatter(currency_code => 'USD');

        # when locale is 'en' (English) and currency is USD (US dollars)
        say $curf->format(9.99);  # '$9.99'

README  view on Meta::CPAN

        say $curf->format(9.99);  # '9,99 $ US'

DEPRECATION
    Using the "locale" method as a setter is deprecated. In the future the
    object’s locale will become immutable. Please see issue #38
    <https://github.com/patch/cldr-number-pm5/issues/38> for details and to
    submit comments or concerns.

DESCRIPTION
    Software localization includes much more than just translations.
    Numbers, prices, and even percents should all be localized based on the
    user’s language, script, and region. Fortunately, the Unicode Common
    Locale Data Repository (CLDR) provides locale data and specifications
    for formatting numeric data to use with many of the world’s locales.

    This class provides common attributes shared among the supported
    formatter classes as well as methods to instantiate decimal, percent,
    and currency formatter objects. The value for any attribute (such as
    locale or decimal_sign) will be passed to the formatter objects on
    instantiation but can be overwritten by manually passing another value
    for the attribute or calling a setter method on the formatter object.

  Methods
    decimal_formatter
        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.

    percent_formatter
        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.

    currency_formatter
        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.

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


sub BUILD {}

sub decimal_formatter {
    my ($self, %args) = @_;

    require CLDR::Number::Format::Decimal;
    CLDR::Number::Format::Decimal->new($self->_make_args(%args));
}

sub percent_formatter {
    my ($self, %args) = @_;

    require CLDR::Number::Format::Percent;
    CLDR::Number::Format::Percent->new($self->_make_args(%args));
}

sub currency_formatter {
    my ($self, %args) = @_;

    require CLDR::Number::Format::Currency;

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


    # when locale is 'es' (Spanish)
    say $decf->format(1234.5);  # '1234,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);  # '١٬٢٣٤٫٥'

    # percents
    $perf = $cldr->percent_formatter;

    # when locale is 'tr' (Turkish)
    say $perf->format(0.05);  # '%5'

    # currencies
    $curf = $cldr->currency_formatter(currency_code => 'USD');

    # when locale is 'en' (English) and currency is USD (US dollars)
    say $curf->format(9.99);  # '$9.99'

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

=head1 DEPRECATION

Using the C<locale> method as a setter is deprecated. In the future the object’s
locale will become immutable. Please see
L<issue #38|https://github.com/patch/cldr-number-pm5/issues/38> for details and
to submit comments or concerns.

=head1 DESCRIPTION

Software localization includes much more than just translations. Numbers,
prices, and even percents should all be localized based on the user’s language,
script, and region. Fortunately, the Unicode Common Locale Data Repository
(CLDR) provides locale data and specifications for formatting numeric data to
use with many of the world’s locales.

This class provides common attributes shared among the supported formatter
classes as well as methods to instantiate decimal, percent, and currency
formatter objects. The value for any attribute (such as B<locale> or
B<decimal_sign>) will be passed to the formatter objects on instantiation but
can be overwritten by manually passing another value for the attribute or
calling a setter method on the formatter object.

=head2 Methods

=over

=item decimal_formatter

Returns a decimal formatter, which is a L<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.

=item percent_formatter

Returns a percent formatter, which is a L<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.

=item currency_formatter

Returns a currency formatter, which is a L<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.

=back

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

# This module does not have a publicly supported interface and may change in
# backward incompatible ways in the future.

our $VERSION = '0.19';

our @EXPORT_OK = qw( $N $M $P $C $Q );

# private-use characters as placeholders
# $N: formatted number
# $M: minus sign
# $P: percent sign
# $C: currency sign
# $Q: escaped single quote

our ($N, $M, $P, $C, $Q) = map { chr } 0xF8F0 .. 0xF8F4;

1;

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


our $VERSION      = '0.19';
our $CLDR_VERSION = '29';

our $DATA = {
    root => {
        pattern => {
            at_least => '⩾{0}',
            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 => {
        pattern => {

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

    },
    ar => {
        pattern => {
            at_least => '+{0}',
        },
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{RIGHT-TO-LEFT MARK}-",
            nan => 'ليس رقم',
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{RIGHT-TO-LEFT MARK}+",
        },
        attr => {
            system => 'arab',
        },
    },
    'ar-DZ' => {
        symbol => {
            decimal => ',',

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

            plus => "\N{LEFT-TO-RIGHT MARK}+",
        },
        attr => {
            system => 'latn',
        },
    },
    as => {
        pattern => {
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
        attr => {
            system => 'beng',
        },
    },
    asa => {
        pattern => {
            currency => '#,##0.00 ¤',
        },
    },

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

    },
    'az-Cyrl' => {
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    bas => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    be => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
        attr => {
            min_group => 2,
        },
    },
    bem => {

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

    bm => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    bn => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##,##0.00¤',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
        symbol => {
            nan => 'সংখ্যা না',
        },
        attr => {
            system => 'beng',
        },
    },
    br => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    brx => {
        pattern => {
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
    },
    bs => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => '.',

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

            range => '{0}-{1}',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    ce => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            nan => 'Терхьаш дац',
        },
    },
    cgg => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    chr => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    ckb => {
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{RIGHT-TO-LEFT MARK}-",
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{RIGHT-TO-LEFT MARK}+",
        },
        attr => {
            system => 'arab',
        },
    },
    cs => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    cy => {
        pattern => {
            at_least => '{0}+',
            currency => '¤#,##0.00',
        },
    },
    da => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0}-{1}',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    dav => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    de => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    'de-AT' => {
        pattern => {
            currency => '¤ #,##0.00',
        },
        symbol => {
            group => ' ',
        },
    },
    'de-CH' => {
        pattern => {
            currency => '¤ #,##0.00;¤-#,##0.00',
            percent => '#,##0%',
        },
        symbol => {
            decimal => '.',
            group => q['],
        },
    },
    'de-LI' => {
        pattern => {
            currency => '¤ #,##0.00',
            percent => '#,##0%',
        },
        symbol => {
            decimal => '.',
            group => q['],
        },
    },
    dje => {
        pattern => {
            currency => '#,##0.00¤',
        },
        symbol => {
            group => ' ',
        },
    },
    dsb => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    dua => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    dyo => {
        pattern => {
            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    dz => {
        pattern => {
            currency => '¤#,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0 %',
        },
        symbol => {
            infinity => 'གྲངས་མེད',
            nan => 'ཨང་མད',
        },
        attr => {
            system => 'tibt',
        },
    },
    ebu => {

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

            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    'en-AT' => {
        pattern => {
            currency => '¤ #,##0.00',
            percent => '#,##0 %',
        },
    },
    'en-BE' => {
        pattern => {
            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    'en-CH' => {
        pattern => {
            currency => '¤ #,##0.00;¤-#,##0.00',
        },
    },
    'en-DE' => {
        pattern => {
            percent => '#,##0 %',
        },
    },
    'en-DK' => {
        pattern => {
            percent => '#,##0 %',
        },
    },
    'en-FI' => {
        pattern => {
            percent => '#,##0 %',
        },
        symbol => {
            group => ' ',
        },
    },
    'en-IN' => {
        pattern => {
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
    },
    'en-NL' => {
        pattern => {
            currency => '¤ #,##0.00;¤ -#,##0.00',
        },
    },
    'en-SE' => {
        pattern => {
            percent => '#,##0 %',
        },
        symbol => {
            group => ' ',
        },
    },
    'en-US-u-va-posix' => {
        pattern => {
            currency => '¤ #0.00',
            decimal => '#0.######',
            percent => '#0%',
        },
        symbol => {
            infinity => 'INF',
            permil => '0/00',
        },
    },
    'en-ZA' => {
        symbol => {
            decimal => ',',
            group => ' ',

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

    eo => {
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    es => {
        pattern => {
            at_least => 'Más de {0}',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0}-{1}',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
        attr => {
            min_group => 2,
        },
    },

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

            currency => '¤#,##0.00;¤-#,##0.00',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    'es-CO' => {
        pattern => {
            currency => '¤ #,##0.00',
            percent => '#,##0%',
            range => 'de {0} a {1}',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    'es-CR' => {
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    'es-DO' => {
        pattern => {
            percent => '#,##0%',
        },
    },
    'es-EC' => {
        pattern => {
            currency => '¤#,##0.00;¤-#,##0.00',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },

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

            currency => '¤#,##0.00',
        },
    },
    'es-GT' => {
        pattern => {
            range => '{0} al {1}',
        },
    },
    'es-MX' => {
        pattern => {
            percent => '#,##0%',
        },
    },
    'es-PY' => {
        pattern => {
            currency => '¤ #,##0.00;¤ -#,##0.00',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },

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

            minus => '−',
        },
        attr => {
            min_group => 2,
        },
    },
    eu => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '% #,##0',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    ewo => {
        pattern => {
            currency => '#,##0.00 ¤',
        },

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

        pattern => {
            at_least => "\N{LEFT-TO-RIGHT MARK}{0}+\N{LEFT-TO-RIGHT MARK}",
            currency => "\N{LEFT-TO-RIGHT MARK}¤#,##0.00",
            range => '{0} تا {1}',
        },
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{LEFT-TO-RIGHT MARK}−",
            nan => 'ناعدد',
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",
        },
        attr => {
            system => 'arabext',
        },
    },
    ff => {
        pattern => {
            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    fi => {
        pattern => {
            at_least => 'vähintään {0}',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0}‒{1}',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            minus => '−',
            nan => 'epäluku',
        },
    },
    fil => {
        pattern => {
            at_least => '{0}+',
            currency => '¤#,##0.00',
            range => '{0}-{1}',
        },
    },
    fo => {
        pattern => {
            at_least => '{0} ella meira',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => '.',
            minus => '−',
        },
    },
    fr => {
        pattern => {
            at_least => 'au moins {0}',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    'fr-BE' => {
        symbol => {
            group => '.',
        },
    },
    'fr-CH' => {
        pattern => {
            currency => '¤ #,##0.00;¤-#,##0.00',
            percent => '#,##0%',
        },
        symbol => {
            decimal => '.',
        },
    },
    'fr-LU' => {
        symbol => {
            group => '.',
        },
    },

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

            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    gsw => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            group => '’',
            minus => '−',
        },
    },
    gu => {
        pattern => {
            at_least => '{0}+',
            currency => '¤#,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
            range => '{0}-{1}',
        },
    },
    guz => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    gv => {
        pattern => {

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

        symbol => {
            minus => "\N{LEFT-TO-RIGHT MARK}-",
            plus => "\N{LEFT-TO-RIGHT MARK}+",
        },
    },
    hi => {
        pattern => {
            at_least => '{0}+',
            currency => '¤#,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
    },
    hr => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    hsb => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    hu => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',

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

    },
    jmc => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    ka => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0}-{1}',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            nan => 'არ არის რიცხვი',
        },
        attr => {
            min_group => 2,
        },

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

    },
    kkj => {
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    kl => {
        pattern => {
            currency => '¤#,##0.00;¤-#,##0.00',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    kln => {
        pattern => {
            currency => '¤#,##0.00',
        },

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

        pattern => {
            at_least => '{0}+',
            currency => '¤#,##0.00',
            range => '{0}~{1}',
        },
    },
    kok => {
        pattern => {
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
    },
    ks => {
        pattern => {
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{LEFT-TO-RIGHT MARK}-\N{LEFT-TO-RIGHT MARK}",
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",
        },
        attr => {
            system => 'arabext',
        },
    },
    ksb => {
        pattern => {
            currency => '#,##0.00¤',

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

            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    ksh => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            minus => '−',
            nan => '¤¤¤',
        },
    },
    kw => {
        pattern => {

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

        symbol => {
            decimal => ',',
            group => ' ',
            nan => 'сан эмес',
        },
    },
    lb => {
        pattern => {
            at_least => '⩾ {0}',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    lg => {
        pattern => {
            currency => '#,##0.00¤',
        },

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

            decimal => ',',
            group => '.',
            nan => "ບໍ່\N{ZERO WIDTH SPACE}ແມ່ນ\N{ZERO WIDTH SPACE}ໂຕ\N{ZERO WIDTH SPACE}ເລກ",
        },
    },
    lrc => {
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{LEFT-TO-RIGHT MARK}-\N{LEFT-TO-RIGHT MARK}",
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",
        },
        attr => {
            system => 'arabext',
        },
    },
    lt => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            minus => '−',
        },
    },
    lu => {
        pattern => {
            currency => '#,##0.00¤',

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

        attr => {
            min_group => 3,
            system => 'mymr',
        },
    },
    mzn => {
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{LEFT-TO-RIGHT MARK}-\N{LEFT-TO-RIGHT MARK}",
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",
        },
        attr => {
            system => 'arabext',
        },
    },
    naq => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    nb => {
        pattern => {
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            minus => '−',
        },
    },
    nd => {
        pattern => {
            currency => '¤#,##0.00',

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

            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    nn => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            minus => '−',
        },
    },
    nnh => {
        symbol => {
            decimal => ',',

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

    },
    om => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    or => {
        pattern => {
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
    },
    os => {
        symbol => {
            decimal => ',',
            group => ' ',
            nan => 'НН',
        },
    },
    pa => {
        pattern => {
            at_least => '{0}+',
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
    },
    'pa-Arab' => {
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{LEFT-TO-RIGHT MARK}-\N{LEFT-TO-RIGHT MARK}",
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",
        },
        attr => {
            system => 'arabext',
        },
    },
    pl => {
        pattern => {
            at_least => '{0}+',

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

        },
    },
    ps => {
        pattern => {
            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{LEFT-TO-RIGHT MARK}-\N{LEFT-TO-RIGHT MARK}",
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",
        },
        attr => {
            system => 'arabext',
        },
    },
    pt => {
        pattern => {
            at_least => '+{0}',

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

        },
        symbol => {
            group => ' ',
        },
        attr => {
            min_group => 2,
        },
    },
    qu => {
        pattern => {
            percent => '#,##0 %',
        },
    },
    'qu-BO' => {
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    rm => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            group => '’',
            minus => '−',
        },
    },
    rn => {
        pattern => {
            currency => '#,##0.00¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    ro => {
        pattern => {
            at_least => '>{0}',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0} - {1}',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    rof => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    ru => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0}-{1}',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            nan => 'не число',
        },
    },
    rw => {
        symbol => {

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

        },
    },
    sbp => {
        pattern => {
            currency => '#,##0.00¤',
        },
    },
    se => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            minus => '−',
            nan => '¤¤¤',
        },
    },
    seh => {
        pattern => {

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

    si => {
        pattern => {
            at_least => '{0}+',
            currency => '¤#,##0.00',
        },
    },
    sk => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0} – {1}',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    sl => {
        pattern => {
            currency => '#,##0.00 ¤',

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

            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    sv => {
        pattern => {
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
            range => '{0}‒{1}',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            minus => '−',
            nan => '¤¤¤',
        },
    },
    sw => {

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

        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    ta => {
        pattern => {
            at_least => '{0}+',
            currency => '¤ #,##,##0.00',
            decimal => '#,##,##0.###',
            percent => '#,##,##0%',
        },
    },
    'ta-MY' => {
        pattern => {
            currency => '¤ #,##0.00',
            decimal => '#,##0.###',
            percent => '#,##0%',
        },
    },
    'ta-SG' => {
        pattern => {
            currency => '¤ #,##0.00',
            decimal => '#,##0.###',
            percent => '#,##0%',
        },
    },
    te => {
        pattern => {
            at_least => '{0}+',
            currency => '¤#,##,##0.00',
            decimal => '#,##,##0.###',
        },
    },
    teo => {

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

    },
    ti => {
        pattern => {
            currency => '¤#,##0.00',
        },
    },
    tk => {
        pattern => {
            at_least => '≥{0}',
            currency => '#,##0.00 ¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
            nan => 'san däl',
        },
    },
    to => {
        pattern => {
            at_least => '{0}+',
            range => '{0}—{1}',
        },
        symbol => {
            nan => 'TF',
        },
    },
    tr => {
        pattern => {
            at_least => '{0}+',
            currency => '#,##0.00 ¤',
            percent => '%#,##0',
        },
        symbol => {
            decimal => ',',
            group => '.',
        },
    },
    twq => {
        pattern => {
            currency => '#,##0.00¤',
        },

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

            currency => '#,##0.00 ¤',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    ur => {
        pattern => {
            currency => '¤ #,##,##0.00',
            percent => '#,##,##0%',
        },
        symbol => {
            minus => "\N{LEFT-TO-RIGHT MARK}-",
            plus => "\N{LEFT-TO-RIGHT MARK}+",
        },
    },
    'ur-IN' => {
        symbol => {
            minus => "\N{LEFT-TO-RIGHT MARK}-\N{LEFT-TO-RIGHT MARK}",
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",

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

            decimal => ',',
            group => ' ',
            nan => 'haqiqiy son emas',
        },
    },
    'uz-Arab' => {
        symbol => {
            decimal => 'Ù«',
            group => 'Ù¬',
            minus => "\N{LEFT-TO-RIGHT MARK}-\N{LEFT-TO-RIGHT MARK}",
            percent => 'Ùª',
            permil => '؉',
            plus => "\N{LEFT-TO-RIGHT MARK}+\N{LEFT-TO-RIGHT MARK}",
        },
        attr => {
            system => 'arabext',
        },
    },
    'uz-Cyrl' => {
        symbol => {
            decimal => ',',

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

            currency => '¤#,##0.00',
            range => '{0}-{1}',
        },
        symbol => {
            nan => '非數值',
        },
    },
    zgh => {
        pattern => {
            currency => '#,##0.00¤',
            percent => '#,##0 %',
        },
        symbol => {
            decimal => ',',
            group => ' ',
        },
    },
    zh => {
        pattern => {
            at_least => '{0}+',
            currency => '¤#,##0.00',

lib/CLDR/Number/FAQ.pod  view on Meta::CPAN


This document describes CLDR::Number v0.19, built with Unicode CLDR v29.

=head1 FAQ

=over

=item What’s the status of this project?

L<CLDR::Number> is a stable project used for over a year in production by
Shutterstock on L<www.shutterstock.com> for formatting numbers, percents, and
prices in twenty languages, ten currencies, and myriad countries. It is also
used by L<other projects on the
CPAN|https://metacpan.org/requires/distribution/CLDR-Number?sort=[[2,1]]>.

=item How do I set precision?

The attributes C<minimum_fraction_digits> and C<maximum_fraction_digits> can be
used. If you always want a specific number of fraction digits, also known as
I<precision>, set both of these attributes to the same number.

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

our $VERSION = '0.19';

with qw( CLDR::Number::Role::Format );

has permil => (
    is      => 'rw',
    coerce  => sub { $_[0] ? 1 : 0 },
    default => 0,
);

has percent_sign => (
    is => 'rw',
);

has permil_sign => (
    is => 'rw',
);

has _pattern_type => (
    is      => 'ro',
    default => 'percent',
);

after _trigger_locale => sub {
    my ($self) = @_;

    $self->_build_signs(qw{ percent_sign permil_sign });
};

sub BUILD {}

sub format {
    my ($self, $num) = @_;
    my ($factor, $sign);

    $num = $self->_validate_number(format => $num);
    return undef unless defined $num;

    if ($self->permil) {
        $factor = 1_000;
        $sign   = $self->permil_sign;
    }
    else {
        $factor = 100;
        $sign   = $self->percent_sign;
    }

    my $format = $self->_format_number($num * $factor);
    $format =~ s{$P}{$sign};

    return $format;
}

1;

__END__

=encoding UTF-8

=head1 NAME

CLDR::Number::Format::Percent - Localized percent formatter using the Unicode CLDR

=head1 VERSION

This document describes CLDR::Number::Format::Percent v0.19, built with Unicode
CLDR v29.

=head1 SYNOPSIS

    # either
    use CLDR::Number::Format::Percent;
    $perf = CLDR::Number::Format::Percent->new(locale => 'tr');

    # or
    use CLDR::Number;
    $cldr = CLDR::Number->new(locale => 'tr');
    $perf = $cldr->percent_formatter;

    # when locale is 'tr' (Turkish)
    say $perf->format(0.05);  # '%5'

    # when locale is 'ar' (Arabic)
    say $perf->format(0.05);  # '٥٪'

    # when locale is 'fr' (French)
    say $perf->format(0.05);  # '5 %'

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


=head1 DEPRECATION

Using the C<locale> method as a setter is deprecated. In the future the object’s
locale will become immutable. Please see
L<issue #38|https://github.com/patch/cldr-number-pm5/issues/38> for details and
to submit comments or concerns.

=head1 DESCRIPTION

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

=head2 Methods

=over

=item format

Accepts a number and returns a formatted percent as a character string,
localized for the current locale. If the B<permil> attribute is true, formats as
I<per mil> instead of I<percent>.

=back

=head2 Attributes

The common attributes B<locale>, B<default_locale>, B<numbering_system>,
B<decimal_sign>, B<group_sign>, B<plus_sign>, B<minus_sign>, and B<cldr_version>
are described under L<common attributes in
CLDR::Number|CLDR::Number/"Common Attributes">. All attributes described here
other than B<permil> have defaults that change depending on the current
B<locale>. All string attributes are expected to be character strings, not byte
strings.

=over

=item permil

Default: false (C<0>)

=item percent_sign

Examples: C<%> (percent sign) for all locales

=item permil_sign

Examples: C<‰> (per mille sign) for B<root> and almost all locales

=item pattern

Examples: C<#,##0%> for B<root>, B<en>; C<#,##0 %> for B<de>, B<fr>;
C<#,##,##0%> for B<hi>, B<bn>, B<en-IN>, and other locales of the Indian
subcontinent

t/format.t  view on Meta::CPAN

use strict;
use warnings;
use charnames qw( :full );
use open qw( :encoding(UTF-8) :std );
use Test::More tests => 60;
use Test::Warn;
use CLDR::Number;

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

$decf->locale('en');
is $decf->format(5.0),              '5';
is $decf->format(0),                '0';
is $decf->format(.5),               '0.5';
is $decf->format(.05),              '0.05';
is $decf->format(.005),             '0.005';
is $decf->format(50_000.05),        '50,000.05';
is $decf->format(5_000_000.05),     '5,000,000.05';

t/format.t  view on Meta::CPAN


warning_is {
    is $decf->range(undef, 1), undef, 'decimal range when A is undef';
} 'Use of uninitialized value in CLDR::Number::Format::Decimal::range';

warning_is {
    is $decf->range(1, undef), undef, 'decimal range when B is undef';
} 'Use of uninitialized value in CLDR::Number::Format::Decimal::range';

warning_is {
    my $perf = $cldr->percent_formatter;
    is $perf->format(undef), undef, 'percent format when undef';
} 'Use of uninitialized value in CLDR::Number::Format::Percent::format';

warning_is {
    my $curf = $cldr->currency_formatter(currency_code => 'EUR');
    is $curf->format(undef), undef, 'currency format when undef';
} 'Use of uninitialized value in CLDR::Number::Format::Currency::format';

$decf->locale('it');
$perf->locale('it');
$curf->locale('it');

t/format.t  view on Meta::CPAN

];

warnings_are {
    is $decf->range('5X', '10X'), '5-10', 'decimal range when both not all num';
} [
    q{Argument "5X" isn't numeric in CLDR::Number::Format::Decimal::range},
    q{Argument "10X" isn't numeric in CLDR::Number::Format::Decimal::range},
];

warning_is {
    is $perf->format('X'), '0%', 'percent format when not num';
} q{Argument "X" isn't numeric in CLDR::Number::Format::Percent::format};

warning_is {
    is $perf->format('1.5X'), '150%', 'percent format when not all num';
} q{Argument "1.5X" isn't numeric in CLDR::Number::Format::Percent::format};

warning_is {
    is $curf->format('X'), '0,00 €', 'currency format when not num';
} q{Argument "X" isn't numeric in CLDR::Number::Format::Currency::format};

warning_is {
    is $curf->format('1.5X'), '1,50 €', 'currency format when not all num';
} q{Argument "1.5X" isn't numeric in CLDR::Number::Format::Currency::format};

t/from-icu4c.t  view on Meta::CPAN

use open qw( :encoding(UTF-8) :std );
use Test::More tests => 2;
use CLDR::Number;

my $cldr = CLDR::Number->new;

# Tests adapted from ICU4C:
# source/test/intltest/numfmtst.cpp

# NumberFormatTest::TestPerMill
my $perf = $cldr->percent_formatter(permil => 1);
$perf->pattern('###.###%');
is $perf->format(0.4857), '485.7‰', '0.4857 x ###.###‰';
$perf->permil_sign('m');
is $perf->format(0.4857), '485.7m', '0.4857 x ###.###m';

t/from-twittercldr.t  view on Meta::CPAN

$decf->maximum_fraction_digits(0); is $decf->format(12.1),  '12',   'formats with precision of 0';
$decf->maximum_fraction_digits(1); is $decf->format(12.25), '12,2', 'half-even rounding and formats with precision of 1';

# decimal_formatter_spec.rb
$decf->locale('sv');
is $decf->format(12.0),  '12',    'format positive decimals correctly';
is $decf->format(-12.0), '−12',   'format negative decimals correctly';
$decf->minimum_fraction_digits(3);
is $decf->format(-12), '−12,000', 'respect the minimum_fraction_digits attribute';

# percent_formatter_spec.rb
my $perf = $cldr->percent_formatter(locale => 'da');
is $perf->format(0.12),  '12 %',      'format the number correctly';
is $perf->format(-0.12), '-12 %',     'format negative numbers correctly';
$perf->minimum_fraction_digits(3);
is $perf->format(-0.12), '-12,000 %', 'respect the minimum_fraction_digits attribute';

# currency_formatter_spec.rb
my $curf = $cldr->currency_formatter(locale => 'ko', currency_code => 'USD');
is $curf->format(12),  'US$12.00',  'handles positive numbers';
is $curf->format(-12), '-US$12.00', 'handles negative numbers';
$curf->locale('ms');

t/from-uts35.t  view on Meta::CPAN

# http://www.unicode.org/reports/tr35/tr35-numbers.html

# 2.3 Number Symbols
$decf = $cldr->decimal_formatter(locale => 'en');
$decf->pattern('#,###');         is $decf->format(100_000_000),  '100,000,000',  'group by 3';
$decf->pattern('#,####');        is $decf->format(1_0000_0000),  '1,0000,0000',  'group by 4';
$decf->pattern('#,##,###');      is $decf->format(12_34_56_789), '12,34,56,789', 'primary group by 3, secondary group by 2';
$decf->pattern('###,###,####');  is $decf->format(100_000_0000), '100,000,0000', 'primary group by 4, secondary group by 3';
$decf->pattern('#,##,###,####'); is $decf->format(100_000_0000), '100,000,0000', 'ignore tertiary group';
$decf->pattern('##,#,###,####'); is $decf->format(100_000_0000), '100,000,0000', 'ignore tertiary group';
$perf = $cldr->percent_formatter(locale => 'en', permil => 1);
is $perf->format(1.23), '1,230‰', 'per mille multiplied by 1,000 before formatting';

SKIP: {
    skip 'format_short NYI', 1;
    # 2.4.1 Compact Number Formats
    $decf = $cldr->decimal_formatter(locale => 'fr');
    is $decf->format_short(12_345), '12 K', 'short decimal format';
};

# 2.4.2 Currency Formats

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

use open qw( :encoding(UTF-8) :std );
use Test::More tests => 28;
use CLDR::Number;

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

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


    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)';

t/numbering-system.t  view on Meta::CPAN

use utf8;
use strict;
use warnings;
use open qw( :encoding(UTF-8) :std );
use Test::More tests => 29;
use Test::Warn;
use CLDR::Number;

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

can_ok $cldr, 'numbering_system';
can_ok $decf, 'numbering_system';
can_ok $perf, 'numbering_system';
can_ok $curf, 'numbering_system';

is $cldr->numbering_system, 'latn', 'default numbering system (base)';
is $decf->numbering_system, 'latn', 'default numbering system (decimal)';
is $perf->numbering_system, 'latn', 'default numbering system (percent)';
is $curf->numbering_system, 'latn', 'default numbering system (currency)';

$cldr->numbering_system('thai');
$decf->numbering_system('thai');
$perf->numbering_system('thai');
$curf->numbering_system('thai');

is $cldr->numbering_system, 'thai', 'set numbering system to thai (base)';
is $decf->numbering_system, 'thai', 'set numbering system to thai (decimal)';
is $perf->numbering_system, 'thai', 'set numbering system to thai (percent)';
is $curf->numbering_system, 'thai', 'set numbering system to thai (currency)';

is $decf->format(1234.09), '๑,๒๓๔.๐๙',  'format in thai (decimal)';
is $perf->format(1234.09), '๑๒๓,๔๐๙%',  'format in thai (percent)';
is $curf->format(1234.09), '$๑,๒๓๔.๐๙', 'format in thai (currency)';

$cldr->locale('en-u-nu-latn');
is $cldr->numbering_system, 'latn', 'set numbering system to latn via locale';
$cldr->locale('en-u-nu-thai');
is $cldr->numbering_system, 'thai', 'set numbering system to thai via locale';

$decf->locale('ar');
is $decf->numbering_system, 'arab',     'default numbering system (ar)';
is $decf->format(1234.09),  '١٬٢٣٤٫٠٩', 'format in arab (ar)';

t/objects.t  view on Meta::CPAN

is $decf->rounding_increment,      2, 'rounding spared by locale on create';

$decf = $cldr->decimal_formatter(
    locale  => 'en',
    pattern => '00.0#',
);

is $decf->pattern,   '00.0#', 'pattern spared by locale on create';
is $decf->format(5), '05.0',  'pattern spared by locale on create';

my $perf = $cldr->percent_formatter;
my $curf = $cldr->currency_formatter;

ok !$cldr->can('has'),   'generator: has should not be inherited';
ok !$decf->can('has'),   'decimal: has should not be inherited';
ok !$perf->can('has'),   'percent: has should not be inherited';
ok !$curf->can('has'),   'currency: has should not be inherited';
ok !$cldr->can('croak'), 'generator: croak should not be inherited';
ok !$decf->can('croak'), 'decimal: croak should not be inherited';
ok !$perf->can('croak'), 'percent: croak should not be inherited';
ok !$curf->can('croak'), 'currency: croak should not be inherited';
ok !$decf->can('looks_like_number'), 'looks_like_number should not be inherited';

t/range.t  view on Meta::CPAN

use strict;
use warnings;
use open qw( :encoding(UTF-8) :std );
use Test::More tests => 6;
use CLDR::Number;

my ($cldr, $decf, $perf, $curf);

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

is $decf->range(1, 5),       '1–5',         'range of numbers (en)';
is $perf->range(0.01, 0.05), '1%–5%',       'range of percents (en)';
is $curf->range(1, 5),       '€1.00–€5.00', 'range of prices (en)';

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

is $decf->range(1, 5),       'de 1 a 5',           'range of numbers (es-CO)';
is $perf->range(0.01, 0.05), 'de 1% a 5%',         'range of percents (es-CO)';
is $curf->range(1, 5),       'de $ 1,00 a $ 5,00', 'range of prices (es-CO)';



( run in 0.553 second using v1.01-cache-2.11-cpan-709fd43a63f )