NAME
CLDR::Number::Format::Percent - Localized percent formatter using the Unicode CLDR
VERSION
This document describes CLDR::Number::Format::Percent v0.07, built with Unicode CLDR v24.
SYNOPSIS
# either
use CLDR::Number::Format::Percent;
my $perf = CLDR::Number::Format::Percent->new(locale => 'tr');
# or
use CLDR::Number;
my $cldr = CLDR::Number->new(locale => 'tr');
my $perf = $cldr->percent_formatter;
say $perf->format(0.05); # '%5' (Turkish percent)
$perf->locale('ar');
say $perf->format(0.05); # '٥٪' (Arabic percent)
$perf->locale('fr');
say $perf->format(0.05); # '5 %' (French percent)
$perf->permil(1);
say $perf->format(0.05); # '50 ‰' (French per mil)
DESCRIPTION
Localized percent formatter using the Unicode Common Locale Data Repository (CLDR).
Methods
- format
-
Accepts a number and returns a formatted percent as a character string, localized for the current locale. If the permil attribute is true, formats as per mil instead of percent.
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 other than permil have defaults that change depending on the current locale. All string attributes are expected to be character strings, not byte strings.
- permil
-
Default: false (
0
) - percent_sign
-
Examples:
%
(percent sign) for all locales - permil_sign
-
Examples:
‰
(per mille sign) for root and almost all locales - pattern
-
Examples:
#,##0%
for root, en;#,##0 %
for de, fr;#,##,##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:
0
for all locales - primary_grouping_size
-
Examples:
3
for root and almost all localesNot 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 subcontinentNot used when value is
0
. - rounding_increment
-
Examples:
0
for all locales0
and1
are treated the same.
SEE ALSO
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.