Locale-Unicode-Data

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    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 $all = $cldr->timezones( is_primary => 1 );
    my $all = $cldr->timezones( is_canonical => 1 );
    my $ref = $cldr->timezone_city(
        locale => 'fr',
        timezone => 'Asia/Tokyo',
    );
    my $all = $cldr->timezones_cities;
    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.*/,
    );

Enabling fatal exceptions:

    use v5.34;
    use experimental 'try';
    no warnings 'experimental';
    try
    {
        my $locale = Locale::Unicode::Data->new( fatal => 1 );
        # Missing the 'width' argument
        my $str = $cldr->timezone_names( timezone => 'Asia/Tokyo', locale => 'en' );
        # More code
    }
    catch( $e )
    {
        say "Oops: ", $e->message;
    }

Or, you could set the global variable `$FATAL_EXCEPTIONS` instead:

    use v5.34;
    use experimental 'try';
    no warnings 'experimental';
    $Locale::Unicode::Data::FATAL_EXCEPTIONS = 1;
    try
    {
        my $locale = Locale::Unicode::Data->new;
        # Missing the 'width' argument
        my $str = $cldr->timezone_names( timezone => 'Asia/Tokyo', locale => 'en' );

README.md  view on Meta::CPAN

    This contains all the references behind the CLDR data.

- [BCP47 time zones](#table-bcp47_timezones)

    This contains BCP 47 time zones along with possible aliases and preferred time zone

- [BCP47 currencies](#table-bcp47_currencies)

    This includes the currency ID, an ISO 4217 code, description and a boolean value whether it is obsolete or not.

- [BCP47 extensions](#table-bcp47_extensions)

    This contains the extension category, extension ID, possibly alias, value type and description, and whether it is deprecated,

- [BCP47 extension values](#table-bcp47_values)

    This includes an extension category, and extension ID, an extension value and description.

- [Annotations](#table-annotations)

    This provide annotations (single character like a symbol or an emoji) and default short description for a given `locale`

- [RBNF (Rule-Based Number Format)](#table-rbnf)

    This provides RBNF rules with its grouping value, such as `SpelloutRules` or `OrdinalRules`, the rule set ID such as `spellout-numbering-year` or `spellout-cardinal`, the rule ID such as `Inf` and the rule value.

- [Casings](#table-casings)

    This provides information about casing for a given `locale`

    It includes the `locale`, a `token` such as `currencyName`, `language` and a `value`, such as `lowercase`, `titlecase`

- [Localised calendar terms](#table-calendar_terms)

    This provides localised terms used in different parts of a calendar system, for a given `locale` and `calendar` ID.

- [Localised calendar eras](#table-calendar_eras)

    This provides the localised era names for a given `locale` and `calendar` ID.

- Localised [calendar date, time](#table-calendar_datetime_formats) and [interval formattings](#table-calendar_interval_formats)

    This provides the `CLDR` `DateTime` formattings for a given `locale` and `calendar` ID.

- [Language matching](#table-languages_match)

    This provides a matching between a desired `locale` and what is actually supported, and a `distance` factor, which designed to be the opposite of a percentage, by Unicode. The desired `locale` can be a perl regular expression.

- Unit [constants](#table-unit_constants)

    Some constant values declared for certain measurement units.

- [Unit quantities](#table-unit_quantities)

    Defines the quantity type for certain units.

- [Unit conversions](#table-unit_conversions)

    Define a list of unit conversion from one unit to another.

- [Unit preferences by territories](#unit_prefs)

    Defines what units are preferred by territory.

- [Unit aliases](#table-unit_aliases)

    Provides some aliases for otherwise outdated units.

- [Localised units](#table-units_l10n)

    Localised unit formatting.

- Locale [Number symbols](#table-number_symbols_l10n)

    Value used for each locale for `approximately`, `currency_decimal`, `currency_group`, `decimal`, `exponential`, `group`, `infinity`, `list`, `minus`, `nan`, `per_mille`, `percent`, `plus`, `superscript`, and `time_separator`

    Not every `locale` has a value for each of those properties though.

- [Locale number formatting](#table-number_formats_l10n)

    Localised formatting for currency or decimal numbers.

If you need a more granular access to the data, feel free to access the SQL data directly. You can retrieve a [database handler](#database_handler), as an instance of the [DBI](https://metacpan.org/pod/DBI) API, or you can instantiate a connection yo...

# CONSTRUCTOR

## new

This takes some hash or hash reference of options, instantiates a new [Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData) object, connects to the SQLite database file specified, or the default one, and returns the newly in...

If an error occurred, an [error object](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData%3A%3AException) 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.

- `datafile`

    The file path to the SQLite database file. If this option is not provided, the SQLite database file used will be the one set in the global variable `$DB_FILE`

- `decode_sql_arrays`

    Boolean value to enable or disable automatic decoding of SQL arrays into perl arrays using [JSON::XS](https://metacpan.org/pod/JSON%3A%3AXS)

    This is enabled by default.

    If you want to retrieve a lot of data and do not need access to those arrays, you should deactivate decoding to improve speed.

If an error occurs, an [exception object](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData%3A%3AException) is set and `undef` is returned in scalar context, or an empty list in list context. The [exception object](https://metacpan.org/pod/Local...

    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:

README.md  view on Meta::CPAN

    Known values are: `per-unit`, `prefix`, `regular`

## 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](#table-unit_prefixes) based on the `unit_id` ID provided.

The meaning of the fields are as follows:

- `unit_prefix_id`

    A unique incremental value automatically generated by SQLite.

- `unit_id`

    A `unit` ID

- `symbol`

    A string representing the unit symbol.

- `power`

    A value representing the unit power

- `factor`

    A value representing the unit factor.

## 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](#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](#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](#table-unit_prefs)

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

- `territory`

    A `territory` code as can be found in table [territories](#table-territories)

- `category`

    A category ID. Known categories are: `area`, `concentration`, `consumption`, `duration`, `energy`, `length`, `mass`, `mass-density`, `power`, `pressure`, `speed`, `temperature`, `volume`, `year-duration`

## 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](#table-unit_quantities) based on the `unit_id` ID provided.

The meaning of the fields are as follows:

- `unit_quantity_id`

    A unique incremental value automatically generated by SQLite.

- `base_unit`

    A string representing the base unit.

- `quantity`

    A string representing the unit quantity.

    Known values are: `acceleration`, `angle`, `area`, `catalytic-activity`, `concentration`, `concentration-mass`, `consumption`, `current-density`, `digital`, `duration`, `electric-capacitance`, `electric-charge`, `electric-conductance`, `electric-...

- `status`

    A string representing the unit status.

    Known values are: `undef` and `simple`

- `comment`

    A text providing some comments about this unit quantity.

## 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](#table-unit_quantities)

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

README.md  view on Meta::CPAN

- `description`

    A string field.

- `status`

    A string field.

## Table unit\_conversions

- `unit_conversion_id`

    An integer field.

- `source`

    A string field.

- `base_unit`

    A string field.

- `expression`

    A string field.

- `factor`

    A decimal field.

- `systems`

    A string array field.

- `category`

    A string field.

## Table unit\_prefixes

- `unit_prefix_id`

    An integer field.

- `unit_id`

    A string field.

- `symbol`

    A string field.

- `power`

    An integer field.

- `factor`

    An integer field.

## Table unit\_prefs

- `unit_pref_id`

    An integer field.

- `unit_id`

    A string field.

- `territory`

    A string field.

- `category`

    A string field.

- `usage`

    A string field.

- `geq`

    A decimal field.

- `skeleton`

    A string field.

## Table unit\_quantities

- `unit_quantity_id`

    An integer field.

- `base_unit`

    A string field.

- `quantity`

    A string field.

- `status`

    A string field.

- `comment`

    A string field.

## Table units\_l10n

- `units_l10n_id`

    An integer field.

- `locale`

    A string field.



( run in 0.680 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )