DateTime-Locale-FromCLDR
view release on metacpan or search on metacpan
lib/DateTime/Locale/FromCLDR.pm view on Meta::CPAN
say $locale->native_territory; # North America
my $locale = DateTime::Locale::FromCLDR->new( 'en-XX' );
say $locale->native_territory; # ''
Returns the C<locale>'s C<territory> name as written in the C<locale> own language.
If there is no C<territory> specified in the C<locale>, it will return C<undef>
If there is a C<territory> in the C<locale>, but, somehow, it cannot be found in the C<locale>'s own L<language tree|Locale::Unicode::Data/make_inheritance_tree>, it will return an empty string.
=head2 native_variant
my $locale = DateTime::Locale::FromCLDR->new( 'es-valencia' );
say $locale->native_variant; # Valenciano
my $locale = DateTime::Locale::FromCLDR->new( 'es' );
say $locale->native_variant; # undef
my $locale = DateTime::Locale::FromCLDR->new( 'en-Latn-005' );
say $locale->native_variant; # undef
Returns the C<locale>'s C<variant> name as written in the C<locale> own language.
If there is no C<variant> specified in the C<locale>, it will return C<undef>, and if there is more than one C<variant> it will return the value for the first one only. To get the values for all variants, use L<native_variants|/native_variants>
If there is a C<variant> in the C<locale>, but, somehow, it cannot be found in the C<locale>'s own L<language tree|Locale::Unicode::Data/make_inheritance_tree>, it will return an empty string.
=head2 native_variants
my $locale = DateTime::Locale::FromCLDR->new( 'ja-Latn-fonipa-hepburn-heploc' );
say $locale->native_variants;
# ["IPA Phonetics", "Hepburn romanization", ""]
Here, C<heploc> is an empty string in the array, because it is a deprecated C<variant>, and as such there is no localised name value for it in the C<CLDR> data.
my $locale = DateTime::Locale::FromCLDR->new( 'es' );
say $locale->native_variants; # []
Returns an array reference of each of the C<locale>'s C<variant> subtag name as written in the C<locale> own language.
If there is no C<variant> specified in the C<locale>, it will return an empty array.
If a C<variant> subtag cannot be found in the C<locale>'s own L<language tree|Locale::Unicode::Data/make_inheritance_tree>, then an empty string will be set in the array instead.
Either way, the size of the array will always be equal to the number of variants in the C<locale>
=head2 number_symbols
my $locale = DateTime::Locale::FromCLDR->new( 'en' );
my $ref = $locale->number_symbols;
my $ref = $locale->number_symbols( 'latn' );
# {
# approximately => "~",
# decimal => ".",
# exponential => "E",
# group => ",",
# infinity => "â",
# list => ";",
# minus => "-",
# nan => "NaN",
# per_mille => "â°",
# percent => "%",
# plus => "+",
# superscript => "\xD7",
# time_separator => ":",
# }
Returns an hash reference of a locale's number symbols.
If somehow, none were found, it returns an empty hash reference, so make sure to check for the size of the hash reference returned.
Upon error, it sets an L<exception object|DateTime::Locale::FromCLDR::Exception> and returns C<undef> in scalar context, and an empty list in list context.
Below are all the possible symbols available:
Quoted sentences are from the L<Unicode LDML specifications|https://unicode.org/reports/tr35/tr35-numbers.html#Number_Symbols>.
=over 4
=item * C<approximately>
"Symbol used to denote a value that is approximate but not exact."
For example C<~>, C<â>, C<â>, C<ç´>
=item * C<currency_decimal>
"Used as the decimal separator instead of using the regular C<decimal> separator"
For example C<.>
=item * C<currency_group>
"Used as the group separator instead of using the regular C<group> separator"
For example C<.>
=item * C<decimal>
"Separates the integer and fractional part of the number."
For example C<.>, C<Ù«>, C<,>
=item * C<exponential>
"Symbol separating the mantissa and exponent values."
For example C<E>, C<e>, C<Ã10^>, C<·10^>
=item * C<group>
"Separates clusters of integer digits to make large numbers more legible"
For example C<,>, C<Ù¬>, C<.>, C<Ø>, C<â>, C<â¹>
=item * C<infinity>
"The infinity sign. Corresponds to the IEEE infinity bit pattern."
For example C<â>, C<INF>
=item * C<list>
"Symbol used to separate numbers in a list intended to represent structured data such as an array; must be different from the decimal value."
For example C<;>
=item * C<minus>
"Symbol used to denote negative value."
For example C<->
Note that, in the CLDR data, although it is always a visually identical representation, the character itself used varies, depending on the locale used. For example: C<-> (C<\x{2D}>) vs C<-> (C<\x{D8}\x{9C}\x{2D}>)
=item * C<nan>
The NaN sign. Corresponds to the IEEE NaN bit pattern.
For example C<NaN>, C<не ÑиÑло>
=item * C<per_mille>
"Symbol used to indicate a per-mille (1/1000th) amount."
For example C<â°>, C<Ø>, C<0/00>
=item * C<percent>
"Symbol used to indicate a percentage (1/100th) amount."
For example C<%>, C<Ùª>
=item * C<plus>
"Symbol used to denote positive value."
For example C<+>
=item * C<superscript>
For example C<Ã>, C<(^)>
=item * C<time_separator>
This is intended to replace "any use of the C<timeSeparator> pattern character in a date-time format pattern"
For example C<:>, C<Ù«>, C<.>
=back
=head2 number_system
my $locale = DateTime::Locale::FromCLDR->new( 'ar-EG' );
say $locale->number_system;
# arab
my $locale = DateTime::Locale::FromCLDR->new( 'ja' );
say $locale->number_system;
# latn
Returns a string representing the number system for the C<locale>
=head2 number_systems
my $locale = DateTime::Locale::FromCLDR->new( 'ar-EG' );
my $ref = $locale->number_systems;
# {
# finance => undef,
# native => undef,
# number_system => "arab",
# traditional => undef,
# }
my $locale = DateTime::Locale::FromCLDR->new( 'ja' );
my $ref = $locale->number_systems;
# {
# finance => "jpanfin",
# native => undef,
# number_system => undef,
( run in 0.659 second using v1.01-cache-2.11-cpan-39bf76dae61 )