NAME

Locale::Unicode::Data - Unicode CLDR SQL Data

SYNOPSIS

use Locale::Unicode::Data;
my $cldr = Locale::Unicode::Data->new;
# Do not decode SQL arrays into perl arrays. Defaults to true
# This uses JSON::XS
my $cldr = Locale::Unicode::Data->new( decode_sql_arrays => 0 );
my $datetime = $cldr->cldr_built;
my $str = $cldr->cldr_maintainer;
my $version = $cldr->cldr_version;
my $dbh = $cldr->database_handler;
my $sqlite_db_file = $cldr->datafile;
my $bool = $cldr->decode_sql_arrays;
# Deactivate automatic SQL arrays decoding
$cldr->decode_sql_arrays(0);
my $tree = $cldr->make_inheritance_tree( 'ja-JP' );
# ['ja-JP', 'ja', 'und']
my $tree = $cldr->make_inheritance_tree( 'es-Latn-001-valencia' );
# ['es-Latn-001-valencia', 'es-Latn-001', 'es-Latn', 'es', 'und']
# But...
my $tree = $cldr->make_inheritance_tree( 'pt-FR' );
# Because exceptionally, the parent of 'pt-FR' is not 'pt', but 'pt-PT'
# ['pt-FR', 'pt-PT', 'pt', 'und']
my $ref = $cldr->split_interval(
    pattern => "E, MMM d, y – E, MMM d, y G",
    greatest_diff => 'y',
);
# ["E, MMM d, y", " – ", "E, MMM d, y G", "E, MMM d, y"]

my $ref = $cldr->alias(
    alias => 'fro',
    type  => 'subdivision',
); # For 'Hauts-de-France'
my $all = $cldr->aliases;
# 'type' can be one of territory, language, zone, subdivision, variant, script
my $all = $cldr->aliases( type => 'territory' );
my $ref = $cldr->annotation( annotation => '{', locale => 'en' );
my $all = $cldr->annotations;
# Get all annotations for locale 'en'
my $all = $cldr->annotations( locale => 'en' );
my $ref = $cldr->bcp47_currency( currid => 'jpy' );
my $all = $cldr->bcp47_currencies;
my $all = $cldr->bcp47_currencies( code => 'JPY' );
# Get all obsolete BCP47 currencies
my $all = $cldr->bcp47_currencies( is_obsolete => 1 );
my $ref = $cldr->bcp47_extension( extension => 'ca' );
my $all = $cldr->bcp47_extensions;
# Get all deprecated BCP47 extensions
my $all = $cldr->bcp47_extensions( deprecated => 1 );
my $ref = $cldr->bcp47_timezone( tzid => 'jptyo' );
my $all = $cldr->bcp47_timezones;
# Get all deprecated BCP47 timezones
my $all = $cldr->bcp47_timezones( deprecated => 1 );
# Returns information about Japanese Imperial calendar
my $ref = $cldr->bcp47_value( value => 'japanese' );
my $all = $cldr->bcp47_timezones;
# Get all the BCP47 values for the category 'calendar'
my $all = $cldr->bcp47_values( category => 'calendar' );
my $all = $cldr->bcp47_values( extension => 'ca' );
my $ref = $cldr->calendar( calendar => 'gregorian' );
my $all = $cldr->calendars;
# Known 'system' value: undef, lunar, lunisolar, other, solar
my $all = $cldr->calendars( system => 'solar' );
my $ref = $cldr->calendar_append_format(
    locale      => 'en',
    calendar    => 'gregorian',
    format_id   => 'Day',
);
my $all = $cldr->calendar_append_formats;
my $all = $cldr->calendar_append_formats(
    locale      => 'en',
    calendar    => 'gregorian',
);
my $ref = $cldr->calendar_available_format(
    locale      => 'en',
    calendar    => 'gregorian',
    format_id   => 'Hms',
    count       => undef,
    alt         => undef,
);
my $all = $cldr->calendar_available_formats;
my $all = $cldr->calendar_available_formats( locale => 'en', calendar => 'gregorian' );
my $ref = $cldr->calendar_cyclic_l10n(
    locale          => 'und',
    calendar        => 'chinese',
    format_set      => 'dayParts',
    format_type     => 'format',
    format_length   => 'abbreviated',
    format_id       => 1,
);
my $all = $cldr->calendar_cyclics_l10n;
my $all = $cldr->calendar_cyclics_l10n( locale => 'en' );
my $all = $cldr->calendar_cyclics_l10n(
    locale          => 'en',
    calendar        => 'chinese',
    format_set      => 'dayParts',
    # Not really needed since 'format' is the only value being currently used
    # format_type   => 'format',
    format_length   => 'abbreviated',
);
my $all = $cldr->calendar_datetime_formats;
my $all = $cldr->calendar_datetime_formats(
    locale      => 'en',
    calendar    => 'gregorian',
);
my $ref = $cldr->calendar_era(
    calendar => 'japanese',
    sequence => 236,
); # Current era 'reiwa'
my $ref = $cldr->calendar_era(
    calendar => 'japanese',
    code => 'reiwa',
); # Current era 'reiwa'
my $all = $cldr->calendar_eras;
my $all = $cldr->calendar_eras( calendar => 'hebrew' );
my $ref = $cldr->calendar_format_l10n(
    locale => 'en',
    calendar => 'gregorian',
    format_type => 'date',
    format_length => 'full',
    format_id => 'yMEEEEd',
);
my $ref = $cldr->calendar_era_l10n(
    locale => 'ja',
    calendar => 'gregorian',
    era_width => 'abbreviated',
    alt => undef,
    era_id => 0,
);
my $array_ref = $cldr->calendar_eras_l10n;
# Filter based on the 'locale' field value
my $array_ref = $cldr->calendar_eras_l10n( locale => 'en' );
# Filter based on the 'calendar' field value
my $array_ref = $cldr->calendar_eras_l10n( calendar => 'gregorian' );
# or a combination of multiple fields:
my $array_ref = $cldr->calendar_eras_l10n(
    locale => 'en',
    calendar => 'gregorian',
    era_width => 'abbreviated',
    alt => undef
);
my $ref = $cldr->calendar_format_l10n(
    locale => 'en',
    calendar => 'gregorian',
    # date, time
    format_type => 'date',
    # full, long, medium, short
    format_length => 'full',
    format_id => 'yMEEEEd',
);
my $all = $cldr->calendar_formats_l10n;
my $all = $cldr->calendar_formats_l10n(
    locale      => 'en',
    calendar    => 'gregorian',
);
my $all = $cldr->calendar_formats_l10n(
    locale => 'en',
    calendar => 'gregorian',
    format_type => 'date',
    format_length => 'full',
);
my $ref = $cldr->calendar_interval_format(
    locale              => 'en',
    calendar            => 'gregorian',
    greatest_diff_id    => 'd',
    format_id           => 'GyMMMEd',
    alt                 => undef,
);
my $all = $cldr->calendar_interval_formats;
my $all = $cldr->calendar_interval_formats(
    locale      => 'en',
    calendar    => 'gregorian',
);
my $ref = $cldr->calendar_term(
    locale          => 'und',
    calendar        => 'gregorian',
    # format, stand-alone
    term_context    => 'format',
    # abbreviated, narrow, wide
    term_width      => 'abbreviated',
    term_name       => 'am',
);
my $array_ref = $cldr->calendar_terms;
my $array_ref = $cldr->calendar_terms(
    locale => 'und',
    calendar => 'japanese'
);
my $array_ref = $cldr->calendar_terms(
    locale          => 'und',
    calendar        => 'gregorian',
    term_type       => 'day',
    term_context    => 'format',
    term_width      => 'abbreviated',
);
my $ref = $cldr->casing( locale => 'fr', token => 'currencyName' );
my $all = $cldr->casings;
my $all = $cldr->casings( locale => 'fr' );
my $ref = $cldr->code_mapping( code => 'US' );
my $all = $cldr->code_mappings;
my $all = $cldr->code_mappings( type => 'territory' );
my $all = $cldr->code_mappings( type => 'currency' );
my $all = $cldr->code_mappings( alpha3 => 'USA' );
my $all = $cldr->code_mappings( numeric => 840 ); # U.S.A.
my $all = $cldr->code_mappings( numeric => [">835", "<850"] ); # U.S.A.
my $all = $cldr->code_mappings( fips => 'JP' ); # Japan
my $all = $cldr->code_mappings( fips => undef, type => 'currency' );
my $ref = $cldr->collation( collation => 'ducet' );
my $all = $cldr->collations;
my $all = $cldr->collations( description => qr/Chinese/ );
my $ref = $cldr->collation_l10n( locale => 'en', collation => 'ducet' );
my $all = $cldr->collations_l10n( locale => 'en' );
my $all = $cldr->collations_l10n( locale => 'ja', locale_name => qr/中国語/ );
my $ref = $cldr->currency( currency => 'JPY' ); # Japanese Yen
my $all = $cldr->currencies;
my $all = $cldr->currencies( is_obsolete => 1 );
my $ref = $cldr->currency_info( territory => 'FR', currency => 'EUR' );
my $all = $cldr->currencies_info;
my $all = $cldr->currencies_info( territory => 'FR' );
my $all = $cldr->currencies_info( currency => 'EUR' );
my $ref = $cldr->currency_l10n(
    locale      => 'en',
    count       => undef,
    currency    => 'JPY',
);
my $all = $cldr->currencies_l10n;
my $all = $cldr->currencies_l10n( locale => 'en' );
my $all = $cldr->currencies_l10n(
    locale      => 'en',
    currency    => 'JPY',
);
my $ref = $cldr->date_field_l10n(
    locale          => 'en',
    field_type      => 'day',
    field_length    => 'narrow',
    relative        => -1,
);
my $all = $cldr->date_fields_l10n;
my $all = $cldr->date_fields_l10n( locale => 'en' );
my $all = $cldr->date_fields_l10n(
    locale          => 'en',
    field_type      => 'day',
    field_length    => 'narrow',
);
my $ref = $cldr->day_period( locale => 'fr', day_period => 'noon' );
my $all = $cldr->day_periods;
my $all = $cldr->day_periods( locale => 'ja' );
# Known values for day_period: afternoon1, afternoon2, am, evening1, evening2, 
# midnight, morning1, morning2, night1, night2, noon, pm
my $all = $cldr->day_periods( day_period => 'noon' );
my $ids = $cldr->interval_formats(
    locale => 'en',
    calendar => 'gregorian',
);
# Retrieve localised information for certain type of data
# Possible types are: annotation, calendar_append_format, calendar_available_format, 
# calendar_cyclic, calendar_era, calendar_format, calendar_interval_formats, 
# calendar_term, casing, currency, date_field, locale, number_format, number_symbol
# script, subdivision, territory, unit, variant
my $ref = $cldr->l10n(
    type => 'annotation',
    locale => 'en',
    annotation => '{',
);
my $ref = $cldr->l10n(
    # or just 'append'
    type => 'calendar_append_format',
    locale => 'en',
    calendar => 'gregorian',
    format_id => 'Day',
);
my $ref = $cldr->l10n(
    # or just 'available'
    type => 'calendar_available_format',
    locale => 'ja',
    calendar => 'japanese',
    format_id => 'GyMMMEEEEd',
);
my $ref = $cldr->l10n(
    # or just 'cyclic'
    type => 'calendar_cyclic',
    locale => 'ja',
    calendar => 'chinese',
    format_set => 'dayParts',
    # 1..12
    format_id => 1,
);
# Retrieve the information on current Japanese era (Reiwa)
my $ref = $cldr->l10n(
    # or just 'era'
    type => 'calendar_era',
    locale => 'ja',
    calendar => 'japanese',
    # abbreviated, narrow
    # 'narrow' contains less data than 'abbreviated'
    era_width => 'abbreviated',
    era_id => 236,
);
my $ref = $cldr->l10n(
    type => 'calendar_format',
    locale => 'ja',
    calendar => 'gregorian',
    format_id => 'yMEEEEd',
);
my $ref = $cldr->l10n(
    # or just 'interval'
    type => 'calendar_interval_format',
    locale => 'ja',
    calendar => 'gregorian',
    format_id => 'yMMM',
);
my $ref = $cldr->l10n(
    type => 'calendar_term',
    locale => 'ja',
    calendar => 'gregorian',
    term_name => 'mon',
);
my $ref = $cldr->l10n(
    type => 'casing',
    locale => 'fr',
    token => 'currencyName',
);
my $ref = $cldr->l10n(
    type => 'currency',
    locale => 'ja',
    currency => 'EUR',
);
my $ref = $cldr->l10n(
    # or just 'field'
    type => 'date_field',
    locale => 'ja',
    # Other possible values:
    # day, week, month, quarter, year, hour, minute, second,
    # mon, tue, wed, thu, fri, sat, sun
    field_type  => 'day',
    # -1 for yesterday, 0 for today, 1 for tomorrow
    relative => -1,
);
my $ref = $cldr->l10n(
    type => 'locale',
    locale => 'ja',
    locale_id => 'fr',
);
my $ref = $cldr->l10n(
    type => 'number_format',
    locale => 'ja',
    number_type => 'currency',
    format_id => '10000',
);
my $ref = $cldr->l10n(
    # or just 'symbol'
    type => 'number_symbol',
    locale => 'en',
    number_system => 'latn',
    property => 'decimal',
);
my $ref = $cldr->l10n(
    type => 'script',
    locale => 'ja',
    script => 'Kore',
);
my $ref = $cldr->l10n(
    type => 'subdivision',
    locale => 'en',
    subdivision => 'jp13', # Tokyo
);
my $ref = $cldr->l10n(
    type => 'territory',
    locale => 'en',
    territory => 'JP', # Japan
);
my $ref = $cldr->l10n(
    type => 'unit',
    locale => 'en',
    unit_id => 'power3',
);
my $ref = $cldr->l10n(
    type => 'variant',
    locale => 'en',
    variant => 'valencia',
);
my $ref = $cldr->language( language => 'ryu' ); # Central Okinawan (Ryukyu)
my $all = $cldr->languages;
my $all = $cldr->languages( parent => 'gmw' );
my $all = $cldr->language_population( territory => 'JP' );
my $all = $cldr->language_populations;
my $all = $cldr->language_populations( official_status => 'official' );
my $ref = $cldr->likely_subtag( locale => 'ja' );
my $all = $cldr->likely_subtags;
my $ref = $cldr->locale( locale => 'ja' );
my $all = $cldr->locales;
my $ref = $cldr->locale_l10n(
    locale      => 'en',
    locale_id   => 'ja',
    alt         => undef,
);
my $all = $cldr->locales_l10n;
# Returns an array reference of all locale information in English
my $all = $cldr->locales_l10n( locale => 'en' );
# Returns an array reference of all the way to write 'Japanese' in various languages
# This would typically return an array reference of something like 267 hash reference
my $all = $cldr->locales_l10n( locale_id => 'ja' );
# This is basically the same as with the method locale_l10n()
my $all = $cldr->locales_l10n(
    locale      => 'en',
    locale_id   => 'ja',
    alt         => undef,
);
my $ref = $cldr->locales_info( property => 'quotation_start', locale => 'ja' );
my $all = $cldr->locales_infos;
my $ref = $cldr->number_format_l10n(
    locale          => 'en',
    number_system   => 'latn',
    number_type     => 'currency',
    format_length   => 'short',
    format_type     => 'standard',
    alt             => undef,
    count           => 'one',
    format_id       => 1000,
);
my $all = $cldr->number_formats_l10n;
my $all = $cldr->number_formats_l10n( locale => 'en' );
my $all = $cldr->number_formats_l10n(
    locale          => 'en',
    number_system   => 'latn',
    number_type     => 'currency',
    format_length   => 'short',
    format_type     => 'standard',
);
my $ref = $cldr->number_symbol_l10n(
    locale          => 'en',
    number_system   => 'latn',
    property        => 'decimal',
    alt             => undef,
);
my $all = $cldr->number_symbols_l10n;
my $all = $cldr->number_symbols_l10n( locale => 'en' );
my $all = $cldr->number_symbols_l10n(
    locale          => 'en',
    number_system   => 'latn',
);
# See also using rbnf
my $ref = $cldr->number_system( number_system => 'jpan' );
my $all = $cldr->number_systems;
my $ref = $cldr->person_name_default( locale => 'ja' );
my $all = $cldr->person_name_defaults;
my $ref = $cldr->rbnf(
    locale  => 'ja',
    ruleset => 'spellout-cardinal',
    rule_id => 7,
);
my $all = $cldr->rbnfs;
my $all = $cldr->rbnfs( locale => 'ko' );
my $all = $cldr->rbnfs( grouping => 'SpelloutRules' );
my $all = $cldr->rbnfs( ruleset => 'spellout-cardinal-native' );
my $ref = $cldr->reference( code => 'R1131' );
my $all = $cldr->references;
my $ref = $cldr->script( script => 'Jpan' );
my $all = $cldr->scripts;
# 'rtl' ('right-to-left' writing orientation)
my $all = $cldr->scripts( rtl => 1 );
my $all = $cldr->scripts( origin_country => 'FR' );
my $all = $cldr->scripts( likely_language => 'fr' );
my $ref = $cldr->script_l10n(
    locale  => 'en',
    script   => 'Latn',
    alt     => undef,
);
my $all = $cldr->scripts_l10n;
my $all = $cldr->scripts_l10n( locale => 'en' );
my $all = $cldr->scripts_l10n(
    locale  => 'en',
    alt     => undef,
);
my $ref = $cldr->subdivision( subdivision => 'jp12' );
my $all = $cldr->subdivisions;
my $all = $cldr->subdivisions( territory => 'JP' );
my $all = $cldr->subdivisions( parent => 'US' );
my $all = $cldr->subdivisions( is_top_level => 1 );
my $ref = $cldr->subdivision_l10n(
    locale      => 'en',
    # Texas
    subdivision => 'ustx',
);
my $all = $cldr->subdivisions_l10n;
my $all = $cldr->subdivisions_l10n( locale => 'en' );
my $ref = $cldr->territory( territory => 'FR' );
my $all = $cldr->territories;
my $all = $cldr->territories( parent => 150 );
my $ref = $cldr->territory_l10n(
    locale      => 'en',
    territory   => 'JP',
    alt         => undef,
);
my $all = $cldr->territories_l10n;
my $all = $cldr->territories_l10n( locale => 'en' );
my $all = $cldr->territories_l10n(
    locale  => 'en',
    alt     => undef,
);
my $ref = $cldr->time_format( region => 'JP' );
my $all = $cldr->time_formats;
my $all = $cldr->time_formats( region => 'US' );
my $all = $cldr->time_formats( territory => 'JP' );
my $all = $cldr->time_formats( locale => undef );
my $all = $cldr->time_formats( locale => 'en' );
my $ref = $cldr->timezone( timezone => 'Asia/Tokyo' );
my $all = $cldr->timezones;
my $all = $cldr->timezones( territory => 'US' );
my $all = $cldr->timezones( region => 'Asia' );
my $all = $cldr->timezones( tzid => 'sing' );
my $all = $cldr->timezones( tz_bcpid => 'sgsin' );
my $all = $cldr->timezones( metazone => 'Singapore' );
my $all = $cldr->timezones( is_golden => undef );
my $all = $cldr->timezones( is_golden => 1 );
my $ref = $cldr->timezone_info(
    timezone    => 'Asia/Tokyo',
    start       => undef,
);
my $ref = $cldr->timezone_info(
    timezone    => 'Europe/Simferopol',
    start       => ['>1991-01-01', '<1995-01-01'],
);
my $all = $cldr->timezones_info;
my $all = $cldr->timezones_info( metazone => 'Singapore' );
my $all = $cldr->timezones_info( start => undef );
my $all = $cldr->timezones_info( until => undef );
my $ref = $cldr->unit_alias( alias => 'meter-per-second-squared' );
my $all = $cldr->unit_aliases;
my $ref = $cldr->unit_constant( constant => 'lb_to_kg' );
my $all = $cldr->unit_constants;
my $ref = $cldr->unit_conversion( source => 'kilogram' );
my $all = $cldr->unit_conversions;
my $all = $cldr->unit_conversions( base_unit => 'kilogram' );;
my $all = $cldr->unit_conversions( category => 'kilogram' );
my $ref = $cldr->unit_l10n(
    locale          => 'en',
    # long, narrow, short
    format_length   => 'long',
    # compound, regular
    unit_type       => 'regular',
    unit_id         => 'length-kilometer',
    count           => 'one',
    gender          => undef,
    gram_case       => undef,
);
my $all = $cldr->units_l10n;
my $all = $cldr->units_l10n( locale => 'en' );
my $all = $cldr->units_l10n(
    locale          => 'en',
    format_length   => 'long',
    unit_type       => 'regular',
    unit_id         => 'length-kilometer',
    pattern_type    => 'regular',
);
my $ref = $cldr->unit_prefix( unit_id => 'micro' );
my $all = $cldr->unit_prefixes;
my $ref = $cldr->unit_pref( unit_id => 'square-meter' );
my $all = $cldr->unit_prefs;
my $all = $cldr->unit_prefs( territory => 'US' );
my $all = $cldr->unit_prefs( category => 'area' );
my $ref = $cldr->unit_quantity( base_unit => 'kilogram' );
my $all = $cldr->unit_quantities;
my $all = $cldr->unit_quantities( quantity => 'mass' );
my $ref = $cldr->variant( variant => 'valencia' );
my $all = $cldr->variants;
my $ref = $cldr->variant_l10n(
    locale  => 'en',
    alt     => undef,
    variant => 'valencia',
);
my $all = $cldr->variants_l10n;
my $all = $cldr->variants_l10n( locale => 'en' );
my $all = $cldr->variants_l10n(
    locale  => 'en',
    alt     => undef,
);
my $ref = $cldr->week_preference( locale => 'ja' );
my $all = $cldr->week_preferences;

With advanced search:

my $all = $cldr->timezone_info(
    timezone => 'Europe/Simferopol',
    start => ['>1991-01-01','<1995-01-01'],
);
my $all = $cldr->time_formats(
    region => '~^U.*',
);
my $all = $cldr->time_formats(
    region => qr/^U.*/,
);

VERSION

v0.1.0

DESCRIPTION

Locale::Unicode::Data provides access to all the data from the Unicode CLDR (Common Locale Data Repository), using a SQLite database. This is the most extensive up-to-date CLDR data you will find on CPAN. It is provided as SQLite data with a great many number of methods to access those data and make it easy for you to retrieve them. Thanks to SQLite, it is very fast.

SQLite version 3.6.19 (2009-10-14) or higher is required, as this module relies on foreign keys, which were not fully supported before. If the version is anterior, the module will return an error upon object instantiation.

It is designed to be extensive in the scope of data that can be accessed, while at the same time, memory-friendly. Access to each method returns data from the SQLite database on a need-basis.

All the data in this SQLite database are sourced directly and exclusively from the Unicode official CLDR data using a perl script available in this distribution under the scripts directory. Use perldoc scripts/create_database.pl or scripts/create_database.pl --man to access its POD documentation.

The CLDR data includes, by design, outdated ones, such as outdated currencies, country codes, or timezones, that CLDR keeps in order to ensure consistency and reliability. For example, for timezones, the Unicode LDML (Locale Data Markup Language) states that "CLDR contains locale data using a time zone ID from the tz database as the key, stability of the IDs is critical." and "Not all TZDB links are in CLDR aliases. CLDR purposefully does not exactly match the Link structure in the TZDB.". See https://unicode.org/reports/tr35/#Time_Zone_Identifiers

In CLDR parlance, a language is a 2 to 3-characters identifier, whereas a locale includes more information, such as a language, a script, a territory, a variant, and possibly much more information. See for that the Locale::Unicode module and the LDML specifications

Those locales also inherit data from their respective parents. For example, sr-Cyrl-ME would have the following inheritance tree: sr-ME, sr, and und

You can build a locale inheritance tree using make_inheritance_tree, and I recommend Locale::Unicode to build, parse and manipulate locales.

Also, in those CLDR data, there is not always a one-to-one match across all territories (countries) or languages, meaning that some territories or languages have more complete CLDR data than others.

CLDR also uses some default values to avoid repetitions. Those default values are stored in the World territory with code 001 and special language code und (a.k.a. unknown also referred as root)

Please note that the SQLite database is built to not be case sensitive in line with the LDML specifications.

This module documentation is not meant to be a replacement for the Unicode LDML (Locale Data Markup Language) documentation, so please make sure to read the LDML documentation and the CLDR specifications.

The data available from the CLDR via this module includes:

If you need a more granular access to the data, feel free to access the SQL data directly. You can retrieve a database handler, as an instance of the DBI API, or you can instantiate a connection yourself using the database file information

CONSTRUCTOR

new

This takes some hash or hash reference of options, instantiates a new Locale::Unicode::Data object, connects to the SQLite database file specified, or the default one, and returns the newly instantiated object.

If an error occurred, an error object is created and undef is returned in scalar context, or an empty list in list context.

Supported options are as follows. Each option can be later accessed or modified by their associated method.

If an error occurs, an exception object is set and undef is returned in scalar context, or an empty list in list context. The exception object can then be retrieved using error, such as:

my $cldr = Locale::Unicode::Data->new( $somthing_bad ) ||
    die( Locale::Unicode::Data->error );

METHODS

alias

my $ref = $cldr->alias(
    alias => 'i_klingon',
    type  => 'language',
);

This would return an hash reference containing:

{
    alias_id    => 5,
    alias       => 'i_klingon',
    replacement => ["tlh"],
    reason      => 'deprecated',
    type        => 'language',
    comment     => 'Klingon',
}

Returns the language, script, territory, subdivision, variant, or zone aliases stored in table aliases for a given alias and an alias type.

See the LDML specifications for more information.

The meaning of the fields are as follows:

aliases

my $array_ref = $cldr->aliases;
# Filtering based on type
my $array_ref = $cldr->aliases( type => 'language' );
my $array_ref = $cldr->aliases( type => 'script' );
my $array_ref = $cldr->aliases( type => 'subdivision' );
my $array_ref = $cldr->aliases( type => 'territory' );
my $array_ref = $cldr->aliases( type => 'variant' );
my $array_ref = $cldr->aliases( type => 'zone' );

Returns all the data stored in table aliases as an array reference of hash reference.

If an type option is provided, it will return only all the data matching the given type.

See the LDML specifications for more information.

annotation

my $ref = $cldr->annotation( locale => 'en', annotation => '{' );
# Returns an hash reference like this:
{
    annotation_id   => 34686,
    locale          => 'en',
    annotation      => '{',
    defaults        => ["brace", "bracket", "curly brace", "curly bracket", "gullwing", "open curly bracket"],
    tts             => 'open curly bracket',
}

Returns an hash reference of a annotation information from the table annotations for a given locale ID, and annotation value.

As per the LDML specifications, "Annotations provide information about characters, typically used in input. For example, on a mobile keyboard they can be used to do completion. They are typically used for symbols, especially emoji characters."

The meaning of the fields are as follows:

annotations

my $array_ref = $cldr->annotations;
# Get all annotations for locale 'en'
my $array_ref = $cldr->annotations( locale => 'en' );

Returns all annotations information for all known locales from the table annotations as an array reference of hash reference.

Alternatively, you can provide a locale to return all annotation information for that locale

bcp47_currency

my $ref = $cldr->bcp47_currency( currid => 'jpy' );
# Returns an hash reference like this:
{
    bcp47_curr_id   => 133,
    currid          => 'jpy',
    code            => 'JPY',
    description     => 'Japanese Yen',
    is_obsolete     => 0,
}

Returns an hash reference of a BCP47 currency information from the table bcp47_currencies for a given BCP47 currency ID currid.

The meaning of the fields are as follows:

bcp47_currencies

my $array_ref = $cldr->bcp47_currencies;
# Filtering based on ISO4217 currency code
my $array_ref = $cldr->bcp47_currencies( code => 'JPY' );
# Filtering based on obsolete status: 1 = true, 0 = false
my $array_ref = $cldr->bcp47_currencies( is_obsolete => 1 );

Returns all BCP47 currencies information from table bcp47_currencies as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

bcp47_extension

my $ref = $cldr->bcp47_extension( extension => 'ca' );
# Returns an hash reference like this:
{
    bcp47_ext_id    => 1,
    category        => 'calendar',
    extension       => 'ca',
    alias           => 'calendar',
    value_type      => 'incremental',
    description     => 'Calendar algorithm key',
}

Returns an hash reference of a BCP47 extension information from the table bcp47_extensions for a given BCP47 extension.

The meaning of the fields are as follows:

bcp47_extensions

my $array_ref = $cldr->bcp47_extensions;
# Filter based on the 'extension' field value
my $array_ref = $cldr->bcp47_extensions( extension => 'ca' );
# Filter based on the 'deprecated' field value; 1 = true, 0 = false
my $array_ref = $cldr->bcp47_extensions( deprecated => 0 );

Returns all BCP47 extensions information from table bcp47_extensions as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

bcp47_timezone

my $ref = $cldr->bcp47_timezone( tzid => 'jptyo' );
# Returns an hash reference like this:
{
    bcp47_tz_id => 215,
    tzid        => 'jptyo',
    alias       => ["Asia/Tokyo", "Japan"],
    preferred   => undef,
    description => 'Tokyo, Japan',
    deprecated  => undef,
}

Returns an hash reference of a BCP47 timezone information from the table bcp47_timezones for a given BCP47 timezone ID tzid.

The meaning of the fields are as follows:

bcp47_timezones

my $array_ref = $cldr->bcp47_timezones;
# Filter based on the 'deprecated' field value; 1 = true, 0 = false
my $array_ref = $cldr->bcp47_timezones( deprecated => 0 );

Returns all BCP47 timezones information from table bcp47_timezones as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

bcp47_value

my $ref = $cldr->bcp47_value( value => 'japanese' );
# Returns an hash reference like this:
{
    bcp47_value_id  => 16,
    category        => 'calendar',
    extension       => 'ca',
    value           => 'japanese',
    description     => 'Japanese Imperial calendar',
}

Returns an hash reference of a BCP47 value information from the table bcp47_values for a given BCP47 value.

The meaning of the fields are as follows:

bcp47_values

my $array_ref = $cldr->bcp47_values;
# Filter based on the 'category' field value
my $array_ref = $cldr->bcp47_timezones( category => 'calendar' );
# Filter based on the 'extension' field value
my $array_ref = $cldr->bcp47_timezones( extension => 'ca' );

Returns all BCP47 values information from table bcp47_values as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

calendar

my $ref = $cldr->calendar( calendar => 'gregorian' );
# Returns an hash reference like this:
{
    calendar_id => 1,
    calendar    => 'gregorian',
    system      => 'solar',
    inherits    => undef,
    description => undef,
}

Returns an hash reference of a calendar information from the table calendars for a given calendar value.

The meaning of the fields are as follows:

calendars

my $array_ref = $cldr->calendars;
# Known 'system' value: undef, lunar, lunisolar, other, solar
my $array_ref = $cldr->calendars( system => 'solar' );
my $array_ref = $cldr->calendars( inherits => 'gregorian' );

Returns all calendar information from table calendars as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

calendar_append_format

my $ref = $cldr->calendar_append_format(
    locale      => 'en',
    calendar    => 'gregorian',
    format_id   => 'Day',
);
# Returns an hash reference like this:
{
    cal_append_fmt_id   => 12,
    locale              => 'en',
    calendar            => 'gregorian',
    format_id           => 'Day',
    format_pattern      => '{0} ({2}: {1})',
}

Returns an hash reference of a calendar localised append format information from the table calendar_append_formats for a given format ID format_id, locale ID and calendar ID.

The meaning of the fields are as follows:

See the LDML specifications for more information.

calendar_append_formats

my $array_ref = $cldr->calendar_append_formats;
# Filter based on the 'locale' field value
my $array_ref = $cldr->calendar_append_formats( locale => 'en' );
# Filter based on the 'calendar' field value
my $array_ref = $cldr->calendar_append_formats( calendar => 'gregorian' );
# or a combination of those two:
my $array_ref = $cldr->calendar_append_formats(
    locale => 'en',
    calendar => 'gregorian'
);

Returns all calendar appended formats information from table calendar_append_formats as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

See also the method l10n

calendar_available_format

my $ref = $cldr->calendar_available_format(
    locale      => 'en',
    calendar    => 'gregorian',
    format_id   => 'Hms',
    # optional
    count       => undef,
    # optional
    alt         => undef,
);
# Returns an hash reference like this:
{
    cal_avail_fmt_id    => 2662,
    locale              => 'en',
    calendar            => 'gregorian',
    format_id           => 'Hms',
    format_pattern      => 'HH:mm:ss',
    count               => undef,
    alt                 => undef,
}

Returns an hash reference of a calendar localised available format information from the table calendar_available_formats for a given format ID format_id, calendar ID and a locale ID.

The meaning of the fields are as follows:

See the LDML specifications for more informations.

calendar_available_formats

my $array_ref = $cldr->calendar_available_formats;
# Filter based on the 'locale' field value
my $array_ref = $cldr->calendar_available_formats( locale => 'en' );
# Filter based on the 'calendar' field value
my $array_ref = $cldr->calendar_available_formats( calendar => 'gregorian' );
# or a combination of those two:
my $array_ref = $cldr->calendar_available_formats(
    locale => 'en',
    calendar => 'gregorian',
);

Returns all calendar available formats information from table calendar_available_formats as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

See also the method l10n

calendar_cyclic_l10n

my $ref = $cldr->calendar_cyclic_l10n(
    locale          => 'und',
    calendar        => 'chinese',
    format_set      => 'dayParts',
    format_type     => 'format',
    format_length   => 'abbreviated',
    format_id       => 1,
);
# Returns an hash reference like this:
{
    cal_int_fmt_id  => 1014,
    locale          => 'und',
    calendar        => 'chinese',
    format_set      => 'dayParts',
    format_type     => 'format',
    format_length   => 'abbreviated',
    format_id       => 1,
    format_pattern  => 'zi',
}

Returns an hash reference of a script localised information from the table scripts_l10n for a given format ID format_id, ID a locale ID, a calendar ID, a format set format_set, a format type format_type and a format length format_length.

The meaning of the fields are as follows:

See the LDML specifications for more information.

calendar_cyclics_l10n

my $all = $cldr->calendar_cyclics_l10n;
my $all = $cldr->calendar_cyclics_l10n( locale => 'en' );
my $all = $cldr->calendar_cyclics_l10n(
    locale          => 'en',
    calendar        => 'chinese',
    format_set      => 'dayParts',
    # Not really needed since 'format' is the only value being currently used
    # format_type   => 'format',
    format_length   => 'abbreviated',
);

Returns all calendar cyclic localised formats information from table calendar_cyclics_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

calendar_datetime_format

my $ref = $cldr->calendar_datetime_format(
    locale          => 'en',
    calendar        => 'gregorian',
    format_length   => 'full',
    format_type     => 'atTime',
);
# Returns an hash reference like this:
{
    cal_dt_fmt_id   => 434,
    locale          => 'en',
    calendar        => 'gregorian',
    format_length   => 'full',
    format_type     => 'atTime',
    format_pattern  => "{1} 'at' {0}",
}

Returns an hash reference of a calendar localised datetime format information from the table calendar_datetime_formats for a given locale ID, calendar ID, format_length, and format_type.

The meaning of the fields are as follows:

calendar_datetime_formats

my $array_ref = $cldr->calendar_datetime_formats;
# Filter based on the 'locale' field value
my $array_ref = $cldr->calendar_datetime_formats( locale => 'en' );
# Filter based on the 'calendar' field value
my $array_ref = $cldr->calendar_datetime_formats( calendar => 'gregorian' );
# or a combination of those two:
my $array_ref = $cldr->calendar_datetime_formats(
    locale => 'en',
    calendar => 'gregorian',
);

Returns all calendar datetime formats information from table calendar_datetime_formats as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

See also the method l10n

calendar_era_l10n

my $ref = $cldr->calendar_era_l10n(
    locale => 'ja',
    calendar => 'gregorian',
    era_width => 'abbreviated',
    alt => undef,
    era_id => 0,
);
# Returns an hash reference like this:
{
    cal_era_l10n_id => 2844,
    locale          => 'ja',
    calendar        => 'gregorian',
    era_width       => 'abbreviated',
    era_id          => 0,
    alt             => undef,
    locale_name     => '紀元前',
}

Returns an hash reference of a calendar era information from the table calendar_eras_l10n for a given calendar value, a locale, a era_width, and a era_id. If no alt value is provided, it will default to undef

The meaning of the fields are as follows:

calendar_eras_l10n

my $array_ref = $cldr->calendar_eras_l10n;
# Filter based on the 'locale' field value
my $array_ref = $cldr->calendar_eras_l10n( locale => 'en' );
# Filter based on the 'calendar' field value
my $array_ref = $cldr->calendar_eras_l10n( calendar => 'gregorian' );
# or a combination of multiple fields:
my $array_ref = $cldr->calendar_eras_l10n(
    locale => 'en',
    calendar => 'gregorian',
    era_width => 'abbreviated',
    alt => undef
);

Returns all calendar localised eras information from table calendar_eras_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

See also the method l10n

calendar_format_l10n

my $ref = $cldr->calendar_format_l10n(
    locale => 'ja',
    calendar => 'gregorian',
    # date, time
    format_type => 'date',
    # full, long, medium, short
    format_length => 'full',
);
# Returns an hash reference like this:
{
    cal_fmt_l10n_id => 906,
    locale          => 'ja',
    calendar        => 'gregorian',
    format_type     => 'date',
    format_length   => 'full',
    alt             => undef,
    format_id       => 'yMEEEEd',
    format_pattern  => 'y年M月d日EEEE',
}

Returns an hash reference of a calendar format information from the table calendar_formats_l10n for a given calendar value, a locale, a format_type, and a format_length.

The meaning of the fields are as follows:

calendar_formats_l10n

my $array_ref = $cldr->calendar_formats_l10n;
# Filter based on the 'locale' field value
my $array_ref = $cldr->calendar_formats_l10n( locale => 'en' );
# Filter based on the 'calendar' field value
my $array_ref = $cldr->calendar_formats_l10n( calendar => 'gregorian' );
# or a combination of multiple fields:
my $array_ref = $cldr->calendar_formats_l10n(
    locale => 'en',
    calendar => 'gregorian',
    format_type => 'date',
    format_length => 'full',
);

Returns all calendar localised date and time formats information from table calendar_formats_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

See also the method l10n

calendar_interval_format

my $ref = $cldr->calendar_interval_format(
    locale              => 'en',
    calendar            => 'gregorian',
    greatest_diff_id    => 'd',
    format_id           => 'GyMMMEd',
    alt                 => undef,
);
# Returns an hash reference like this:
{
    cal_int_fmt_id      => 3846,
    locale              => 'en',
    calendar            => 'gregorian',
    format_id           => 'GyMMMEd',
    greatest_diff_id    => 'd',
    format_pattern      => 'E, MMM d – E, MMM d, y G',
    alt                 => undef,
    part1               => 'E, MMM d',
    separator           => ' – ',
    part2               => 'E, MMM d, y G',
    repeating_field     => 'E, MMM d',
}

Returns an hash reference of a calendar localised interval information from the table calendar_interval_formats for a given calendar ID and a locale ID. If no alt value is provided, it will default to undef

Pay particular attention to the fields part1, separator and part2 that are designed to greatly make it easy for you to format and use the interval format pattern.

Without those special fields, it would not be possible to properly format an interval.

The meaning of the fields are as follows:

See LDML specifications for more information.

calendar_interval_formats

my $array_ref = $cldr->calendar_interval_formats;
# Filter based on the 'locale' field value
my $array_ref = $cldr->calendar_interval_formats( locale => 'en' );
# Filter based on the 'calendar' field value
my $array_ref = $cldr->calendar_interval_formats( calendar => 'gregorian' );
# or a combination of those two:
my $array_ref = $cldr->calendar_interval_formats(
    locale      => 'en',
    calendar    => 'gregorian',
);

Returns all calendar interval formats information from table calendar_interval_formats as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

See also the method l10n

calendar_l10n

my $ref = $cldr->calendar_l10n(
    locale => 'en',
    caendar => 'japanese',
);
# Returns an hash reference like:
{
    calendar_l10n_id => 506,
    locale => 'en',
    calendar => 'japanese',
    locale_name => 'Japanese Calendar',
}

Returns an hash reference of a calendar localised information from the table calendars_l10n for a given locale ID, and calendar ID.

The meaning of the fields are as follows:

calendars_l10n

my $all = $cldr->calendars_l10n;
my $all = $cldr->calendars_l10n(
    locale => 'en',
);

Returns all calendar localised information from table calendars_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

calendar_term

my $ref = $cldr->calendar_term(
    locale          => 'und',
    calendar        => 'gregorian',
    # format, stand-alone
    term_context    => 'format',
    # abbreviated, narrow, wide
    term_width      => 'abbreviated',
    term_name       => 'am',
);
# Returns an hash reference like:
{
    cal_term_id     => 23478,
    locale          => 'und',
    calendar        => 'gregorian',
    term_type       => 'day_period',
    term_context    => 'format',
    term_width      => 'abbreviated',
    alt             => undef,
    yeartype        => undef,
    term_name       => 'am',
    term_value      => 'AM',
}

Returns an hash reference of a calendar term information from the table calendar_terms for a given locale, calendar, term_context, term_width, term_name value, alt and yeartype value. If no alt or yeartype value is provided, it will default to undef

You can also query for multiple value at the same time, and this will return an array reference of hash reference instead:

my $all = $cldr->calendar_term(
    locale          => 'und',
    calendar        => 'gregorian',
    # format, stand-alone
    term_context    => 'format',
    # abbreviated, narrow, wide
    term_width      => 'abbreviated',
    term_name       => [qw( am pm )],
);
# Returns an array reference like:
[
    {
        cal_term_id     => 23478,
        locale          => 'und',
        calendar        => 'gregorian',
        term_type       => 'day_period',
        term_context    => 'format',
        term_width      => 'abbreviated',
        alt             => undef,
        yeartype        => undef,
        term_name       => 'am',
        term_value      => 'AM',
    },
    {
        cal_term_id     => 23479,
        locale          => 'und',
        calendar        => 'gregorian',
        term_type       => 'day_period',
        term_context    => 'format',
        term_width      => 'abbreviated',
        alt             => undef,
        yeartype        => undef,
        term_name       => 'pm',
        term_value      => 'PM',
    },
]

See the section on "Advanced Search" for more information.

The meaning of the fields are as follows:

See also the Unicode LDMD specifications

calendar_terms

my $array_ref = $cldr->calendar_terms;
my $array_ref = $cldr->calendar_terms(
    locale => 'und',
    calendar => 'japanese'
);
my $array_ref = $cldr->calendar_terms(
    locale          => 'und',
    calendar        => 'gregorian',
    term_type       => 'day',
    term_context    => 'format',
    term_width      => 'abbreviated',
);

Returns all calendar terms information from table calendar_terms as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

See also the Unicode LDMD specifications

casing

my $ref = $cldr->casing( locale => 'fr', token => 'currencyName' );
# Returns an hash reference like:
{
    casing_id   => 926,
    locale      => 'fr',
    token       => 'currencyName',
    value       => 'lowercase',
}

Returns an hash reference of a calendar information from the table casings for a given token value.

The meaning of the fields are as follows:

casings

my $all = $cldr->casings;
my $all = $cldr->casings( locale => 'fr' );

Returns all casing information from table casings as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

cldr_built

my $datetime = $cldr->cldr_built; # 2024-07-01T05:57:29

Return the ISO8601 datetime in GMT of when this data were built.

Note, this is just a string, not a DateTime object. If you want a DateTime object, maybe do something like:

use DateTime::Format::Strptime;
my $fmt = DateTime::Format::Strptime->new( pattern => '%FT%T' );
my $dt = $fmt->parse_datetime( $cldr->cldr_built );

cldr_maintainer

my $str = $cldr->cldr_maintainer; # Jacques Deguest

Returns a string representing the name of the person who created this SQLite database of CLDR data.

cldr_version

my $version = $cldr->cldr_version; # 45.0

Return the Unicode CLDR version number of the data.

Note, this is just a string. You may want to turn it into an object for comparison, such as:

use version;
my $vers = version->parse( $cldr->cldr_version );

Or, maybe:

use Changes::Version;
my $vers = Changes::Version->new( $cldr->cldr_version );

say $vers > $other_version;

code_mapping

my $ref = $cldr->code_mapping( code => 'US' );
# Returns an hash reference like:
{
    code_mapping_id => 263,
    code            => 'US',
    alpha3          => 'USA',
    numeric         => 840,
    fips10          => undef,
    type            => 'territory',
}

Returns an hash reference of a code mapping information from the table code_mappings for a given code value.

The meaning of the fields are as follows:

code_mappings

my $all = $cldr->code_mappings;
my $all = $cldr->code_mappings( type => 'territory' );
my $all = $cldr->code_mappings( type => 'currency' );
my $all = $cldr->code_mappings( alpha3 => 'USA' );
my $all = $cldr->code_mappings( numeric => 840 ); # U.S.A.
my $all = $cldr->code_mappings( fips => 'JP' ); # Japan
my $all = $cldr->code_mappings( fips => undef, type => 'currency' );

Returns all code mapping information from table code_mappings as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

collation

my $ref = $cldr->collation(
    collation => 'ducet',
);
# Returns an hash reference like this:
{
    collation => 'ducet',
    description => 'Dictionary style ordering (such as in Sinhala)',
}

Returns an hash reference of a collation information from the table collations for a given collation ID.

The meaning of the fields are as follows:

collations

my $all = $cldr->collations;
my $all = $cldr->collations( collation => 'ducet' );
my $all = $cldr->collations( description => qr/Chinese/ );

Returns all collations information from table collations as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

collation_l10n

my $ref = $cldr->collation_l10n(
    collation => 'ducet',
    locale => 'en',
);
# Returns an hash reference like this:
{
    collation_l10n_id   => 323,
    locale              => 'en',
    collation           => 'ducet',
    locale_name         => 'Default Unicode Sort Order',
}

Returns an hash reference of a collation localised information from the table collations_l10n for a given collation ID and a locale ID.

The meaning of the fields are as follows:

collations_l10n

my $all = $cldr->collations_l10n;
my $all = $cldr->collations_l10n( locale => 'en' );
my $all = $cldr->collations_l10n(
    locale => 'en',
    collation => 'ducet',
);

Returns all collations information from table collations_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

currency

my $ref = $cldr->currency( currency => 'JPY' ); # Japanese Yen
# Returns an hash reference like:
{
    currency_id     => 133,
    currency        => 'JPY',
    digits          => 0,
    rounding        => 0,
    cash_digits     => undef,
    cash_rounding   => undef,
    is_obsolete     => 0,
    status          => 'regular',
}

Returns an hash reference of a code mapping information from the table currencies for a given currency code.

The meaning of the fields are as follows:

currencies

my $all = $cldr->currencies;
my $all = $cldr->currencies( is_obsolete => 1 );

Returns all currencies information from table currencies as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

currency_info

my $ref = $cldr->currency_info(
    currency    => 'EUR',
    territory'  => 'FR',
);
# Returns an hash reference like this:
{
    currency_info_id    => 165,
    territory           => 'FR',
    currency            => 'EUR',
    start               => '1999-01-01',
    until               => undef,
    is_tender           => 0,
    hist_sequence       => undef,
    is_obsolete         => 0,
}

Returns an hash reference of a currency information from the table currencies_info for a given ]locale ID.

The meaning of the fields are as follows:

See the LDML specifications for more information.

currencies_info

my $all = $cldr->currencies_info;
my $all = $cldr->currencies_info( territory => 'FR' );
my $all = $cldr->currencies_info( currency => 'EUR' );

Returns all currencies information from table currencies_info as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

currency_l10n

my $ref = $cldr->currency_l10n(
    locale      => 'en',
    count       => undef,
    currency    => 'JPY',
);
# Returns an hash reference like this:
{
    curr_l10n_id    => 20924,
    locale          => 'en',
    currency        => 'JPY',
    count           => undef,
    locale_name     => 'Japanese Yen',
    symbol          => '¥',
}

Returns an hash reference of a currency localised information from the table currencies_l10n for a given currency ID, locale ID and count value. If no count value is provided, it will default to undef

The meaning of the fields are as follows:

currencies_l10n

my $all = $cldr->currencies_l10n;
my $all = $cldr->currencies_l10n( locale => 'en' );
my $all = $cldr->currencies_l10n(
    locale      => 'en',
    currency    => 'JPY',
);

Returns all currencies localised information from table currencies_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

database_handler

Returns the current database handler used by the Locale::Unicode::Data object instantiated.

Please note that the database is opened in read-only. If you want to modify it, which I would advise against, you need to instantiate your own DBI connection. Something like this:

my $db_file = $cldr->datafile;
$dbh = DBI->connect( "dbi:SQLite:dbname=${db_file}", '', '' ) ||
    die( "Unable to make connection to Unicode CLDR SQLite database file ${db_file}: ", $DBI::errstr );
# To enable foreign keys:
# See: <https://metacpan.org/release/ADAMK/DBD-SQLite-1.27/view/lib/DBD/SQLite.pm#Foreign-Keys>
$dbh->do("PRAGMA foreign_keys = ON");

datafile

Sets or gets the file path to the SQLite database file. This defaults to the global variable $DB_FILE

date_field_l10n

my $ref = $cldr->date_field_l10n(
    locale          => 'en',
    field_type      => 'day',
    field_length    => 'narrow',
    relative        => -1,
);
# Returns an hash reference like this:
{
    date_field_id   => 2087,
    locale          => 'en',
    field_type      => 'day',
    field_length    => 'narrow',
    relative        => -1,
    locale_name     => 'yesterday',
}

Returns an hash reference of a field localised information from the table date_fields_l10n for a given locale ID, field_type, field_length and relative value.

The meaning of the fields are as follows:

See the LDML specifications for more information.

date_fields_l10n

my $all = $cldr->date_fields_l10n;
my $all = $cldr->date_fields_l10n( locale => 'en' );
my $all = $cldr->date_fields_l10n(
    locale          => 'en',
    field_type      => 'day',
    field_length    => 'narrow',
);

Returns all date fields localised information from table date_fields_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

day_period

my $ref = $cldr->day_period( locale => 'fr', day_period => 'noon' );
# Returns an hash reference like:
{
    day_period_id   => 115,
    locale          => 'fr',
    day_period      => 'noon',
    start           => '12:00',
    until           => '12:00',
}

Returns an hash reference of a day period information from the table day_periods for a given locale code and day_period code.

The meaning of the fields are as follows:

day_periods

my $all = $cldr->day_periods;
my $all = $cldr->day_periods( locale => 'ja' );
# Known values for day_period: afternoon1, afternoon2, am, evening1, evening2,
# midnight, morning1, morning2, night1, night2, noon, pm
my $all = $cldr->day_periods( day_period => 'noon' );

Returns all day periods information from table day_periods as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

decode_sql_arrays

my $bool = $cldr->decode_sql_arrays;
$cldr->decode_sql_arrays(0); # off
$cldr->decode_sql_arrays(1); # on

Sets or gets the boolean value used to specify whether you want this API to automatically decode SQL arrays into perl arrays using JSON::XS

This is set to true by default, upon object instantiation.

error

Used as a mutator, this sets and exception object and returns an Locale::Unicode::NullObject in object context (such as when chaining), or undef in scalar context, or an empty list in list context.

The Locale::Unicode::NullObject class prevents the perl error of Can't call method "%s" on an undefined value (see perldiag). Upon the last method chained, undef is returned in scalar context or an empty list in list context.

For example:

my $locale = Locale::Unicode->new( 'ja' );
$locale->translation( 'my-software' )->transform_locale( $bad_value )->tz( 'jptyo' ) ||
    die( $locale->error );

In this example, jptyo will never be set, because transform_locale triggered an exception that returned an Locale::Unicode::NullObject object catching all further method calls, but eventually we get the error and die.

interval_formats

my $ref = $cldr->interval_formats(
    locale => 'en',
    calendar => 'gregorian',
);

This would return something like:

{
    Bh => [qw( B h )],
    Bhm => [qw( B h m )],
    d => ["d"],
    default => ["default"],
    Gy => [qw( G y )],
    GyM => [qw( G M y )],
    GyMd => [qw( d G M y )],
    GyMEd => [qw( d G M y )],
    GyMMM => [qw( G M y )],
    GyMMMd => [qw( d G M y )],
    GyMMMEd => [qw( d G M y )],
    H => ["H"],
    h => [qw( a h )],
    hm => [qw( a h m )],
    Hm => [qw( H m )],
    hmv => [qw( a h m )],
    Hmv => [qw( H m )],
    Hv => ["H"],
    hv => [qw( a h )],
    M => ["M"],
    Md => [qw( d M )],
    MEd => [qw( d M )],
    MMM => ["M"],
    MMMd => [qw( d M )],
    MMMEd => [qw( d M )],
    y => ["y"],
    yM => [qw( M y )],
    yMd => [qw( d M y )],
    yMEd => [qw( d M y )],
    yMMM => [qw( M y )],
    yMMMd => [qw( d M y )],
    yMMMEd => [qw( d M y )],
    yMMMM => [qw( M y )],
}

This returns an hash reference of interval format ID with their associated greatest difference token for the given locale ID and calendar ID.

The default interval format pattern is something like {0} – {1}, but this changes depending on the locale and is not always available.

{0} is the placeholder for the first datetime and {1} is the placeholder for the second one.

l10n

Returns all localised information for certain type of data as an array reference of hash reference.

The following core parameters must be provided:

Below are each type of data and their associated parameters:

language

my $ref = $cldr->language( language => 'ryu' ); # Central Okinawan (Ryukyu)
# Returns an hash reference like this:
{
    language_id => 6712,
    language    => 'ryu',
    scripts     => ["Kana"],
    territories => ["JPY"],
    parent      => undef,
    alt         => undef,
    status      => 'regular',
}

Returns an hash reference of a language information from the table languages for a given language ID.

The meaning of the fields are as follows:

languages

my $all = $cldr->languages;
my $all = $cldr->languages( parent => 'gmw' );

Returns all languages information from table languages as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

language_population

my $all = $cldr->language_population( territory => 'JP' );
# Returns an array reference of hash references like this:
[
    {
        language_pop_id     => 738,
        territory           => 'JP',
        locale              => 'ja',
        population_percent  => 95,
        literacy_percent    => undef,
        writing_percent     => undef,
        official_status     => 'official',
    },
    {
        language_pop_id     => 739,
        territory           => 'JP',
        locale              => 'ryu',
        population_percent  => 0.77,
        literacy_percent    => undef,
        writing_percent     => 5,
        official_status     => undef,
    },
    {
        language_pop_id     => 740,
        territory           => 'JP',
        locale              => 'ko',
        population_percent  => 0.52,
        literacy_percent    => undef,
        writing_percent     => undef,
        official_status     => undef,
    }
]

Returns an array reference of hash references of a language population information from the table language_population for a given territory ID.

The meaning of the fields are as follows:

language_populations

my $all = $cldr->language_populations;
my $all = $cldr->language_populations( official_status => 'official' );

Returns all language population information from table language_population as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

likely_subtag

my $ref = $cldr->likely_subtag( locale => 'ja' );
# Returns an hash reference like this:
{
    likely_subtag_id    => 297,
    locale              => 'ja',
    target              => 'ja-Jpan-JP',
}

Returns an hash reference for a likely language information from the table likely_subtags for a given locale ID.

The meaning of the fields are as follows:

See the LDML specifications for more information.

likely_subtags

my $all = $cldr->likely_subtags;

Returns all likely subtag information from table likely_subtags as an array reference of hash reference.

No additional parameter is needed.

locale

my $ref = $cldr->locale( locale => 'ja' );
# Returns an hash reference like this:
{
    locale_id   => 3985,
    locale      => 'ja',
    status      => 'regular',
}

Returns an hash reference of locale information from the table locales for a given locale ID.

The meaning of the fields are as follows:

locales

my $all = $cldr->locales;

Returns all locale information from table locales as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

locale_l10n

my $ref = $cldr->locale_l10n(
    locale      => 'en',
    locale_id   => 'ja',
    alt         => undef,
);
# Returns an hash reference like this:
{
    locales_l10n_id => 16746,
    locale          => 'en',
    locale_id       => 'ja',
    locale_name     => 'Japanese',
    alt             => undef,
}

Returns an hash reference of locale localised information from the table locales_l10n for a given locale ID and a locale_id ID and an alt value. If no alt value is provided, it will default to undef.

The locale value is the language, with possibly some additional subtags, in which the information is provided, and the locale_id the locale id whose name will be returned in the language specified by the locale argument.

Valid locales that can be found in the table locales_l10n are, for example: asa, az-Arab (using a script), be-tarask (using a variant), ca-ES-valencia (using a combination of territory and variant), de-AT (using a territory), es-419 (using a region code)

See Locale::Unicode for more information on locales.

The meaning of the fields are as follows:

locales_l10n

my $all = $cldr->locales_l10n;
# Returns an array reference of all locale information in English
my $all = $cldr->locales_l10n( locale => 'en' );
# Returns an array reference of all the way to write 'Japanese' in various languages
# This would typically return an array reference of something like 267 hash reference
my $all = $cldr->locales_l10n( locale_id => 'ja' );
# This is basically the same as with the method locale_l10n()
my $all = $cldr->locales_l10n(
    locale      => 'en',
    locale_id   => 'ja',
    alt         => undef,
);

Returns all locale localised information from table locales_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

locales_info

my $ref = $cldr->locales_info(
    property => 'quotation_start',
    locale => 'ja',
);
# Returns an hash reference like this:
{
    locales_info_id => 361,
    locale          => 'ja',
    property        => 'quotation_start',
    value           => '「',
}

Returns an hash reference of locale properties information from the table locales_info for a given locale ID and a property value.

The meaning of the fields are as follows:

locales_infos

 my $all = $cldr->locales_infos;

Returns all locale properties information from table locales_info as an array reference of hash reference.

No additional parameter is needed.

make_inheritance_tree

This takes a locale, such as ja or ja-JP, or es-ES-valencia and it will return an array reference of inheritance tree of locales. This means the provided locale's parent, its grand-parent, etc until it reaches the root, which, under the LDML specifications is defined by und

For example:

# Japanese
my $tree = $cldr->make_inheritance_tree( 'ja-JP' );

produces:

['ja-JP', 'ja', 'und']

However, there are exceptions and the path is not always linear.

For example:

# Portugese in France
my $tree = $cldr->make_inheritance_tree( 'pt-FR' );

produces:

['pt-FR', 'pt-PT', 'pt', 'und']

Why? Because the CLDR (Common Locale Data Repository) specifies a special parent for locale pt-FR. Those exceptions are defined in common/supplemental/supplementalData.xml with xpath /supplementalData/parentLocales/parentLocale

Another example:

# Traditional Chinese
my $tree = $cldr->make_inheritance_tree( 'yue-Hant' );

Normally, this parent would be yue, which would lead to simplified Chinese, which would not be appropriate, so instead the CLDR provides zh-Hant

['yue-Hant', 'zh-Hant', 'und']

If an error occurred, it will set an error object and return undef in scalar context and an empty list in list context.

See the LDML specifications about inheritance and about locale inheritance and matching for more information.

normalise

This takes a Unicode locale, which can be quite complexe, and normalise it, by replacing outdated elements (subtag) in the language, script, territory or variant part.

it returns a new Locale::Unicode object

You can also call this method as normalize

number_format_l10n

my $ref = $cldr->number_format_l10n(
    locale          => 'en',
    number_system   => 'latn',
    number_type     => 'currency',
    format_length   => 'short',
    format_type     => 'standard',
    alt             => undef,
    count           => 'one',
    format_id       => 1000,
);
# Returns an hash reference like this:
{
    number_format_id    => 2897,
    locale              => 'en',
    number_system       => 'latn',
    number_type         => 'currency',
    format_length       => 'short',
    format_type         => 'standard',
    format_id           => 1000,
    format_pattern      => '¤0K',
    alt                 => undef,
    count               => 'one',
}

Returns an hash reference of a number format localised information from the table number_formats_l10n for a given locale ID, number system, number_type, format_length, format_type, alt, count, and format_id. If no alt value or count value is provided, it will default to undef

The meaning of the fields are as follows:

See the LDML specifications for more information.

number_formats_l10n

my $all = $cldr->number_formats_l10n;
my $all = $cldr->number_formats_l10n( locale => 'en' );
my $all = $cldr->number_formats_l10n(
    locale          => 'en',
    number_system   => 'latn',
    number_type     => 'currency',
    format_length   => 'short',
    format_type     => 'standard',
);

Returns all number formats localised information from table number_formats_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

number_symbol_l10n

my $ref = $cldr->number_symbol_l10n(
    locale          => 'en',
    number_system   => 'latn',
    property        => 'decimal',
    alt             => undef,
);
# Returns an hash reference like this:
{
    number_symbol_id    => 113,
    locale              => 'en',
    number_system       => 'latn',
    property            => 'decimal',
    value               => '.',
    alt                 => undef,
}

Returns an hash reference of a script localised information from the table scripts_l10n for a given locale ID, number_system, property value and alt value. If no alt value is provided, it will default to undef

The meaning of the fields are as follows:

number_symbols_l10n

my $all = $cldr->number_symbols_l10n;
my $all = $cldr->number_symbols_l10n( locale => 'en' );
my $all = $cldr->number_symbols_l10n(
    locale          => 'en',
    number_system   => 'latn',
);

Returns all number symbols localised information from table number_symbols_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

number_system

my $ref = $cldr->number_system( number_system => 'jpan' );
# Returns an hash reference like this:
{
    numsys_id       => 35,
    number_system   => 'jpan',
    digits          => ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"],
    type            => 'algorithmic',
}

Returns an hash reference of a number_system information from the table number_systems for a given number_system ID.

There are 88 known number systems.

The meaning of the fields are as follows:

number_systems

 my $all = $cldr->number_systems;

Returns all number systems information from table number_systems as an array reference of hash reference.

There are 88 known number systems:

number_system_l10n

my $ref = $cldr->number_system_l10n(
    number_system => 'jpan',
    locale => 'en',
);
# Returns an hash reference like this:
{
    num_sys_l10n_id => 1335,
    locale          => 'en',
    number_system   => 'jpan',
    locale_name     => 'Japanese Numerals',
    alt             => undef,
}

Returns an hash reference of a number_system localised information from the table number_systems_l10n for a given number_system ID and a locale ID.

There are 190 known localised information for number systems.

The meaning of the fields are as follows:

number_systems_l10n

 my $all = $cldr->number_systems_l10n;

Returns all number systems localised information from table number_systems_l10n as an array reference of hash reference.

person_name_default

my $ref = $cldr->person_name_default( locale => 'ja' );
# Returns an hash reference like this:
{
    pers_name_def_id    => 3,
    locale              => 'ja',
    value               => 'surnameFirst',
}

Returns an hash reference of a person name defaults information from the table person_name_defaults for a given locale ID.

Be aware that there are very few data. This is because the entry for locale und (undefined), contains the default value. Thus, if there is no data for the desired locale, you should fallback to und

This is the way the Unicode CLDR data is structured.

person_name_defaults

my $all = $cldr->person_name_defaults;

Returns all person name defaults information from table person_name_defaults as an array reference of hash reference.

rbnf

my $ref = $cldr->rbnf(
    locale => 'ja',
    ruleset => 'spellout-cardinal',
    rule_id => 7,
);
# Returns an hash reference like this:
{
    rbnf_id     => 7109,
    locale      => 'ja',
    grouping    => 'SpelloutRules',
    ruleset     => 'spellout-cardinal',
    rule_id     => '7',
    rule_value  => '七;',
}

Returns an hash reference of a RBNF (Rule-Based Number Format) information from the table rbnf for a given locale ID, a rule set ruleset and a rule ID rule_id.

The meaning of the fields are as follows:

rbnfs

my $all = $cldr->rbnfs;
my $all = $cldr->rbnfs( locale => 'ko' );
my $all = $cldr->rbnfs( grouping => 'SpelloutRules' );
my $all = $cldr->rbnfs( ruleset => 'spellout-cardinal-native' );

Returns all RBNF (Rule-Based Number Format) information from table rbnf as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

reference

my $ref = $cldr->reference( code => 'R1131' );
# Returns an hash reference like this:
{
    ref_id  => 132,
    code    => 'R1131',
    uri     => 'http://en.wikipedia.org/wiki/Singapore',
    description => 'English is the first language learned by half the children by the time they reach preschool age; using 92.6% of pop for the English figure',
}

Returns an hash reference of a reference information from the table refs for a given code.

references

my $all = $cldr->references;

Returns all reference information from table refs as an array reference of hash reference.

No additional parameter is needed.

script

my $ref = $cldr->script( script => 'Jpan' );
# Returns an hash reference like this:
{
    script_id       => 73,
    script          => 'Jpan',
    rank            => 5,
    sample_char     => '3048',
    id_usage        => 'RECOMMENDED',
    rtl             => 0,
    lb_letters      => 1,
    has_case        => 0,
    shaping_req     => 0,
    ime             => 1,
    density         => 2,
    origin_country  => 'JP',
    likely_language => 'ja',
    status          => 'regular',
}

Returns an hash reference of a script information from the table scripts for a given script ID.

The meaning of the fields are as follows:

The information is quoted directly from the CLDR data.

See also the Unicode list of known scripts

scripts

my $all = $cldr->scripts;
my $all = $cldr->scripts( rtl => 1 );
my $all = $cldr->scripts( origin_country => 'FR' );
my $all = $cldr->scripts( likely_language => 'fr' );

Returns all scripts information from table scripts as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

script_l10n

my $ref = $cldr->script_l10n(
    locale  => 'en',
    script   => 'Latn',
    alt     => undef,
);
# Returns an hash reference like this:
{
    scripts_l10n_id => 3636,
    locale          => 'en',
    script          => 'Latn',
    locale_name     => 'Latin',
    alt             => undef,
}

Returns an hash reference of a script localised information from the table scripts_l10n for a given script ID and a locale ID and a alt value. If no alt value is provided, it will default to undef

The meaning of the fields are as follows:

scripts_l10n

my $all = $cldr->scripts_l10n;
my $all = $cldr->scripts_l10n( locale => 'en' );
my $all = $cldr->scripts_l10n(
    locale  => 'en',
    alt     => undef,
);

Returns all localised scripts information from table scripts_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

split_interval

my $ref = $cldr->split_interval(
    pattern => $string,
    greatest_diff => 'd',
) || die( $cldr->error );

This takes an hash or hash reference of options and it returns a 4-elements array reference containing:

The required options are:

This method is provided as a convenience, but the interval formats data in the database have already been pre-processed, so you do not have to do it.

subdivision

my $ref = $cldr->subdivision( subdivision => 'jp12' );
# Returns an hash reference like this:
{
    subdivision_id  => 2748,
    territory       => 'JP',
    subdivision     => 'jp12',
    parent          => 'JP',
    is_top_level    => 1,
    status          => 'regular',
}

Returns an hash reference of a subdivision information from the table subdivisions for a given subdivision ID.

The meaning of the fields are as follows:

subdivisions

my $all = $cldr->subdivisions;
my $all = $cldr->subdivisions( territory => 'JP' );
my $all = $cldr->subdivisions( parent => 'US' );
my $all = $cldr->subdivisions( is_top_level => 1 );

Returns all subdivisions information from table subdivisions as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

subdivision_l10n

my $ref = $cldr->subdivision_l10n(
    locale      => 'en',
    # Texas
    subdivision => 'ustx',
);
# Returns an hash reference like this:
{
    subdiv_l10n_id  => 56463,
    locale          => 'en',
    subdivision     => 'ustx',
    locale_name     => 'Texas',
}

Returns an hash reference of a script localised information from the table scripts_l10n for a given subdivision ID and a locale ID.

The meaning of the fields are as follows:

See the LDML specifications for more information.

subdivisions_l10n

my $all = $cldr->subdivisions_l10n;
my $all = $cldr->subdivisions_l10n( locale => 'en' );

Returns all subdivisions localised information from table subdivisions_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

territory

my $ref = $cldr->territory( territory => 'FR' );
# Returns an hash reference like this:
{
    territory_id        => 118,
    territory           => 'FR',
    parent              => 155,
    gdp                 => 2856000000000,
    literacy_percent    => 99,
    population          => 67848200,
    languages           => ["fr", "en", "es", "de", "oc", "it", "pt", "pcd", "gsw", "br", "co", "hnj", "ca", "eu", "nl", "frp", "ia"],
    contains            => undef,
    currency            => 'EUR',
    calendars           => undef,
    min_days            => 4,
    first_day           => 1,
    weekend             => undef,
    status              => 'regular',
}

Returns an hash reference of a territory information from the table territories for a given territory ID.

The meaning of the fields are as follows:

territories

my $all = $cldr->territories;
my $all = $cldr->territories( parent => 150 );

Returns all territories information from table territories as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

territory_l10n

my $ref = $cldr->territory_l10n(
    locale      => 'en',
    territory   => 'JP',
    alt         => undef,
);
# Returns an hash reference like this:
{
    terr_l10n_id    => 13385,
    locale          => 'en',
    territory       => 'JP',
    locale_name     => 'Japan',
    alt             => undef,
}

Returns an hash reference of a territory localised information from the table territories_l10n for a given territory ID and a locale ID and an alt value. If no alt value is provided, it will default to undef

The meaning of the fields are as follows:

territories_l10n

my $all = $cldr->territories_l10n;
my $all = $cldr->territories_l10n( locale => 'en' );
my $all = $cldr->territories_l10n(
    locale  => 'en',
    alt     => undef,
);

Returns all localised territories information from table territories_l10n as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

time_format

my $ref = $cldr->time_format( region => 'JP' );
# Returns an hash reference like this:
{
    time_format_id  => 86,
    region          => 'JP',
    territory       => 'JP',
    locale          => undef,
    time_format     => 'H',
    time_allowed    =>  ["H", "K", "h"],
}

Returns an hash reference of a time format information from the table time_formats for a given region ID.

The meaning of the fields are as follows:

See the LDML specifications for more information.

time_formats

my $all = $cldr->time_formats;
my $all = $cldr->time_formats( region => 'US' );
my $all = $cldr->time_formats( territory => 'JP' );
my $all = $cldr->time_formats( locale => undef );
my $all = $cldr->time_formats( locale => 'en' );

Returns all time formats information from table time_formats as an array reference of hash reference.

A combination of the following fields may be provided to filter the information returned:

timezone

my $ref = $cldr->timezone( timezone => 'Asia/Tokyo' );
# Returns an hash reference like this:
{
    timezone_id => 281,
    timezone    => 'Asia/Tokyo',
    territory   => 'JP',
    region      => 'Asia',
    tzid        => 'japa',
    metazone    => 'Japan',
    tz_bcpid    => 'jptyo',
    is_golden   => 1,
}

Returns an hash reference of a time zone information from the table timezones based on the timezone ID provided.

The meaning of the fields are as follows:

timezones

my $array_ref = $cldr->timezones;
# Or, providing with some filtering arguments
# Returns all the timezones for the country code 'JP'
my $array_ref = $cldr->timezones( territory => 'JP' );
# Returns all the timezones for the region code 'Asia'
my $array_ref = $cldr->timezones( region => 'Asia' );
 # Returns all the timezones that match the CLDR timezone ID 'japa'
my $array_ref = $cldr->timezones( tzid => 'japa' );
 # Returns all the timezones that match the BCP47 timezone ID 'jptyo'
my $array_ref = $cldr->timezones( tz_bcpid => 'jptyo' );
 # Returns all the timezones that have the CLDR metazone 'Japan'
my $array_ref = $cldr->timezones( metazone => 'Japan' );
# Returns all the timezones that are 'golden' timezones
my $array_ref = $cldr->timezones( is_golden => 1 );

Returns all the timezone information as an array reference of hash reference from the table timezones

You can adjust the data return by using a combination of the following filtering arguments:

timezone_info

my $ref = $cldr->timezone_info(
    timezone    => 'Europe/Simferopol',
    start       => '1994-04-30T21:00:00',
);
# Returns an hash reference like this:
{
    tzinfo_id   => 594,
    timezone    => 'Europe/Simferopol',
    metazone    => 'Moscow',
    start       => '1994-04-30T21:00:00',
    until       => '1997-03-30T01:00:00',
}

or, maybe, simpler, using the advanced search:

my $ref = $cldr->timezone_info(
    timezone    => 'Europe/Simferopol',
    start       => ['>1992-01-01', '<1995-01-01'],
);

That way, you do not need to know the exact date.

Returns an hash reference of a timezone historical information from the table timezones_info for a given timezone ID and a start datetime. If no start value is provided, it will default to undef

The meaning of the fields are as follows:

timezones_info

my $all = $cldr->timezones_info;
my $all = $cldr->timezones_info( timezone => 'Europe/Simferopol' );
my $all = $cldr->timezones_info( metazone => 'Singapore' );
my $all = $cldr->timezones_info( start => undef );
my $all = $cldr->timezones_info( until => undef );

Returns all the timezone information as an array reference of hash reference from the table timezones_info

You can adjust the data return by using a combination of the following filtering arguments:

unit_alias

my $ref = $cldr->unit_alias( alias => 'meter-per-second-squared' );
# Returns an hash reference like this:
{
    unit_alias_id   => 3,
    alias           => 'meter-per-second-squared',
    target          => 'meter-per-square-second',
    reason          => 'deprecated',
}

Or, maybe simpler, using the advanced search:

my $ref = $cldr->unit_alias( alias => '~^meter.*' );

or

my $ref = $cldr->unit_alias( alias => qr/^meter.*/ );

Returns an hash reference of a unit alias information from the table unit_aliases based on the alias ID provided.

unit_aliases

my $all = $cldr->unit_aliases;

Returns all the unit alias information as an array reference of hash reference from the table unit_aliases

No additional parameter is needed.

unit_constant

my $ref = $cldr->unit_constant( constant => 'lb_to_kg' );
# Returns an hash reference like this:
{
    unit_constant_id    => 1,
    constant            => 'lb_to_kg',
    expression          => 0.45359237,
    value               => 0.45359237,
    description         => undef,
    status              => undef,
}

Returns an hash reference of a unit constant information from the table unit_constants based on the constant ID provided.

The meaning of the fields are as follows:

unit_constants

my $all = $cldr->unit_constants;

Returns all the unit constants information as an array reference of hash reference from the table unit_constants

No additional parameter is needed.

unit_conversion

my $ref = $cldr->unit_conversion( source => 'kilogram' );
# Returns an hash reference like this:
{
    unit_conversion_id  => 9,
    source              => 'kilogram',
    base_unit           => 'kilogram',
    expression          => undef,
    factor              => undef,
    systems             => ["si", "metric"],
    category            => 'mass',
}

Returns an hash reference of a unit conversion information from the table unit_conversions based on the source ID provided.

The meaning of the fields are as follows:

unit_conversions

my $all = $cldr->unit_conversions;
my $all = $cldr->unit_conversions( base_unit => 'kilogram' );;
my $all = $cldr->unit_conversions( category => 'mass' );

Returns all the unit conversion information as an array reference of hash reference from the table unit_conversions

A combination of the following fields may be provided to filter the information returned:

unit_l10n

my $ref = $cldr->unit_l10n(
    unit_id         => 'length-kilometer',
    locale          => 'en',
    # long, narrow, short
    format_length   => 'long',
    # compound, regular
    unit_type       => 'regular',
    count           => 'one',
    gender          => undef,
    gram_case       => undef,
);
# Returns an hash reference like this:
{
    units_l10n_id   => 25599,
    locale          => 'en',
    format_length   => 'long',
    unit_type       => 'regular',
    unit_id         => 'length-kilometer',
    unit_pattern    => '{0} kilometer',
    pattern_type    => 'regular',
    locale_name     => 'kilometers',
    count           => 'one',
    gender          => undef,
    gram_case       => undef,
}

Returns an hash reference of a unit localised information from the table units_l10n for a given locale ID, format_length, unit_type, unit_id, count, gender, gram_case.

If no count, gender, or gram_case value is provided, it will default to undef

The meaning of the fields are as follows:

See the LDML specifications for more information.

units_l10n

my $all = $cldr->units_l10n;
my $all = $cldr->units_l10n( locale => 'en' );
my $all = $cldr->units_l10n(
    locale          => 'en',
    format_length   => 'long',
    unit_type       => 'regular',
    unit_id         => 'length-kilometer',
    pattern_type    => 'regular',
);

Returns all the unit prefixes information as an array reference of hash reference from the table units_l10n

A combination of the following fields may be provided to filter the information returned:

unit_prefix

my $ref = $cldr->unit_prefix( unit_id => 'micro' );
# Returns an hash reference like this:
{
    unit_prefix_id  => 9,
    unit_id         => 'micro',
    symbol          => 'μ',
    power           => 10,
    factor          => -6,
}

Returns an hash reference of a unit prefix information from the table unit_prefixes based on the unit_id ID provided.

The meaning of the fields are as follows:

unit_prefixes

my $all = $cldr->unit_prefixes;

Returns all the unit prefixes information as an array reference of hash reference from the table unit_prefixes

No additional parameter is needed.

unit_pref

my $ref = $cldr->unit_pref( unit_id => 'square-meter' );
# Returns an hash reference like this:
{
    unit_pref_id    => 3,
    unit_id         => 'square-meter',
    territory       => '001',
    category        => 'area',
    usage           => 'default',
    geq             => undef,
    skeleton        => undef,
}

Returns an hash reference of a unit preference information from the table unit_prefs based on the unit_id ID provided.

unit_prefs

my $all = $cldr->unit_prefs;
my $all = $cldr->unit_prefs( territory => 'US' );
my $all = $cldr->unit_prefs( category => 'area' );

Returns all the unit preferences information as an array reference of hash reference from the table unit_prefs

A combination of the following fields may be provided to filter the information returned:

unit_quantity

my $ref = $cldr->unit_quantity( base_unit => 'kilogram' );
# Returns an hash reference like this:
{
    unit_quantity_id    => 4,
    base_unit           => 'kilogram',
    quantity            => 'mass',
    status              => 'simple',
    comment             => undef,
}

Returns an hash reference of a unit quantities information from the table unit_quantities based on the unit_id ID provided.

The meaning of the fields are as follows:

unit_quantities

my $all = $cldr->unit_quantities;
my $all = $cldr->unit_quantities( quantity => 'mass' );

Returns all the unit quantities information as an array reference of hash reference from the table unit_quantities

A combination of the following fields may be provided to filter the information returned:

variant

my $ref = $cldr->variant( variant => 'valencia' );
# Returns an hash reference like this:
{
    variant_id  => 111,
    variant     => 'valencia',
    status      => 'regular',
}

Returns an hash reference of a variant information from the table variants based on the variant ID provided.

The meaning of the fields are as follows:

variants

my $all = $cldr->variants;

Returns all the variants information as an array reference of hash reference from the table variants

No additional parameter is needed.

variant_l10n

my $ref = $cldr->variant_l10n(
    variant => 'valencia',
    locale  => 'en',
    alt     => undef,
);
# Returns an hash reference like this:
{
    var_l10n_id => 771,
    locale      => 'en',
    variant     => 'valencia',
    locale_name => 'Valencian',
    alt         => undef,
}

Returns an hash reference of a variant localised information from the table variants_l10n for a given variant ID and a locale ID and an alt value. If no alt value is provided, it will default to undef

The meaning of the fields are as follows:

variants_l10n

my $all = $cldr->variants_l10n;
my $all = $cldr->variants_l10n( locale => 'en' );
my $all = $cldr->variants_l10n(
    locale  => 'en',
    alt     => undef,
);

Returns all the variants localised information as an array reference of hash reference from the table variants_l10n

week_preference

my $ref = $cldr->week_preference( locale => 'ja' );
# Returns an hash reference like this:
{
    week_pref_id    => 32,
    locale          => 'ja',
    ordering        => ["weekOfDate", "weekOfMonth"],
}

Returns an hash reference of a week preference information from the table week_preferences for a given locale ID.

The meaning of the fields are as follows:

See the LDML specifications for more information.

week_preferences

my $all = $cldr->week_preferences;

Returns all the week preferences information as an array reference of hash reference from the table week_preferences

SQL Schema

The SQLite SQL schema is available in the file scripts/cldr-schema.sql

The data are populated into the SQLite database using the script located in scripts/create_database.pl and the data accessible from https://github.com/unicode-org/cldr or from https://cldr.unicode.org/index/downloads/

Tables

The SQL schema used to create the SQLite database is available in the scripts directory of this distribution in the file cldr-schema.sql

The tables used are as follows, in alphabetical order:

Table aliases

Table annotations

Table bcp47_currencies

Table bcp47_extensions

Table bcp47_timezones

Table bcp47_values

Table calendar_append_formats

Table calendar_available_formats

Table calendar_cyclics_l10n

Table calendar_datetime_formats

Table calendar_eras

Table calendar_eras_l10n

Table calendar_formats_l10n

Table calendar_interval_formats

Table calendar_terms

Table calendars

Table calendars_l10n

Table casings

Table code_mappings

Table collations_l10n

Table currencies

Table currencies_info

Table currencies_l10n

Table date_fields_l10n

Table day_periods

Table language_population

Table languages

Table languages_match

Table likely_subtags

Table locales

Table locales_info

Table locales_l10n

Table metainfos

Table number_formats_l10n

Table number_symbols_l10n

Table number_systems

Table number_systems_l10n

Table person_name_defaults

Table rbnf

Table refs

Table scripts

Table scripts_l10n

Table subdivisions

Table subdivisions_l10n

Table territories

Table territories_l10n

Table time_formats

Table timezones

Table timezones_info

Table unit_aliases

Table unit_constants

Table unit_conversions

Table unit_prefixes

Table unit_prefs

Table unit_quantities

Table units_l10n

Table variants

Table variants_l10n

Table week_preferences

Format Patterns

The following is taken directly from the Unicode LDML specifications and placed here for your convenience.

Examples:

See the date field symbols table for more details.

See the LDML specifications for more information on the date and time formatting.

Locale Inheritance

When performing data look-ups, some data, such as width, may be missing and the default wide should be used, and sometime, the data is aliased. For example, narrow would be aliased to abbreviated.

Then, there is also a vertical inheritance, whereby a locale fr-CA would lookup up data in its parent fr. When the inheritance is not natural, the LDML specifies a parent. This information can be found in table locales. Ultimately, the root locale with value und is to be used.

See the LDML specifications for more information.

Errors

This module does not die upon errors. Instead it sets an error object that can be retrieved.

When an error occurred, an error object will be set and the method will return undef in scalar context and an empty list in list context.

The only occasions when this module will die is when there is an internal design error, which would be my fault.

Advanced Search

You can specify an operator other than the default = when providing arguments values, by placing it just before the argument value.

Possible explicit operators are:

For example:

my $all = $cldr->timezone_info(
    timezone => 'Europe/Simferopol',
    start => ['>1991-01-01','<1995-01-01'],
);

This would result in:

{
    tzinfo_id   => 594,
    timezone    => 'Europe/Simferopol',
    metazone    => 'Moscow',
    start       => '1994-04-30T21:00:00',
    until       => '1997-03-30T01:00:00',
}

or, using the ~ operator:

my $all = $cldr->time_formats(
    region => '~^U.*',
);
my $all = $cldr->time_formats(
    region => qr/^U.*/,
);

would result in:

[
    {
        time_format_id => 141,
        region => "UA",
        territory => "UA",
        locale => undef,
        time_format => "H",
        time_allowed => [qw( H hB h )],
    },
    {
        time_format_id => 142,
        region => "UZ",
        territory => "UZ",
        locale => undef,
        time_format => "H",
        time_allowed => [qw( H hB h )],
    },
    {
        time_format_id => 155,
        region => "UG",
        territory => "UG",
        locale => undef,
        time_format => "H",
        time_allowed => [qw( hB hb H h )],
    },
    {
        time_format_id => 194,
        region => "UY",
        territory => "UY",
        locale => undef,
        time_format => "h",
        time_allowed => [qw( h H hB hb )],
    },
    {
        time_format_id => 226,
        region => "UM",
        territory => "UM",
        locale => undef,
        time_format => "h",
        time_allowed => [qw( h hb H hB )],
    },
    {
        time_format_id => 227,
        region => "US",
        territory => "US",
        locale => undef,
        time_format => "h",
        time_allowed => [qw( h hb H hB )],
    },
]

For single result methods, i.e. the methods that only return an hash reference, you can provide an array reference instead of a regular string for the primary field you are trying to query. So, for example, using the example above with the timezone info:

my $all = $cldr->timezone_info(
    timezone => 'Europe/Simferopol',
    start => ['>1991-01-01','<1995-01-01'],
);

or, querying the calendar terms:

my $all = $cldr->calendar_term(
    locale          => 'und',
    calendar        => 'gregorian',
    # format, stand-alone
    term_context    => 'format',
    # abbreviated, narrow, wide
    term_width      => 'abbreviated',
    term_name       => [qw( am pm )],
);
# Returns an array reference like:
[
    {
        cal_term_id     => 23478,
        locale          => 'und',
        calendar        => 'gregorian',
        term_type       => 'day_period',
        term_context    => 'format',
        term_width      => 'abbreviated',
        alt             => undef,
        term_name       => 'am',
        term_value      => 'AM',
    },
    {
        cal_term_id     => 23479,
        locale          => 'und',
        calendar        => 'gregorian',
        term_type       => 'day_period',
        term_context    => 'format',
        term_width      => 'abbreviated',
        alt             => undef,
        term_name       => 'pm',
        term_value      => 'PM',
    },
]

Of course, instead of returning an hash reference, as it normally would, it will return an array reference of hash reference.

You can also ensure a certain order based on a field value. For example, you want to retrieve the day terms using calendar_term, but the term_name are string, and we want to ensure the results are sorted in this order: mon, tue, wed, thu, fri, sat and sun

my $terms = $cldr->calendar_terms(
    locale => 'en',
    calendar => 'gregorian',
    term_type => 'day',
    term_context => 'format',
    term_width => 'wide',
    order_by_value => [term_name => [qw( mon tue wed thu fri sat sun )]],
);
my @weekdays = map( $_->{term_name}, @$terms );
# Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday

If we had wanted to put Sunday first, we would have done:

my $terms = $cldr->calendar_terms(
    locale => 'en',
    calendar => 'gregorian',
    term_type => 'day',
    term_context => 'format',
    term_width => 'wide',
    order_by_value => [term_name => [qw( sun mon tue wed thu fri sat )]],
);

The parameter order_by_value supersedes the parameter order that may be provided.

You can specify a particular data type to sort the values returned by SQLite, by providing the argument order, such as:

my $months = $cldr->calendar_terms(
    locale => 'en',
    calendar => 'gregorian',
    term_type => 'month',
    term_context => 'format',
    term_width => 'wide',
    order => [term_name => 'integer'],
);

or, alternatively, using an hash reference with a single key:

my $months = $cldr->calendar_terms(
    locale => 'en',
    calendar => 'gregorian',
    term_type => 'month',
    term_context => 'format',
    term_width => 'wide',
    order => { term_name => 'integer' },
);
my @month_names = map( $_->{term_name}, @$months );
# January, February, March, April, May, June, July, August, September, October, November, December

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Locale::Unicode, DateTime::Locale::FromCLDR, DateTime::Formatter::Unicode, DateTime::Locale::FromData, DateTime::Format::CLDR

COPYRIGHT & LICENSE

Copyright(c) 2024 DEGUEST Pte. Ltd.

All rights reserved

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