DateTime-Locale-FromCLDR

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    # Valencian

    my $locale = DateTime::Locale::FromCLDR->new( 'es' );
    my $script = $locale->variant;
    # undef

    # No such thing as variant 'klingon'. Language 'tlh' exists though :)
    my $locale = DateTime::Locale::FromCLDR->new( 'en-klingon' );
    my $script = $locale->variant;
    # ''

Returns the name of the `locale`'s `variant` in English.

If there is no `variant` specified in the `locale`, it will return `undef`

If there is a `variant` in the `locale`, but, somehow, it cannot be found in the `en` `locale`'s [language tree](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData#make_inheritance_tree), it will return an empty string.

## variant\_code

    my $locale = DateTime::Locale::FromCLDR->new( 'es-valencia' );
    my $script = $locale->variant_code;
    # valencia

    my $locale = DateTime::Locale::FromCLDR->new( 'es-ES' );
    my $script = $locale->variant_code;
    # undef

Returns the `locale`'s `variant` ID, or `undef` if there is none.

## variant\_id

This is an alias for [variant\_code](#variant_code)

## variants

    my $locale = DateTime::Locale::FromCLDR->new( 'es-valencia' );
    my $array = $locale->variants;
    # ["valencia"]

    my $locale = DateTime::Locale::FromCLDR->new( 'ja-Latn-fonipa-hepburn-heploc' );
    my $array = $locale->variants;
    # ["fonipa", "hepburn", "heploc"]

    my $locale = DateTime::Locale::FromCLDR->new( 'en' );
    my $array = $locale->variants;
    # []

This returns an array reference of `variant` subtags for this `locale`, even if there is no variant.

## version

    my $locale = DateTime::Locale::FromCLDR->new( 'en' );
    say $locale->version; # 45.0

Returns the Unicode `CLDR` data version number.

# SERIALISATION

`Locale::Unicode` supports [Storable::Improved](https://metacpan.org/pod/Storable%3A%3AImproved), [Storable](https://metacpan.org/pod/Storable), [Sereal](https://metacpan.org/pod/Sereal) and [CBOR](https://metacpan.org/pod/CBOR%3A%3AXS) serialisation...

For serialisation with [Sereal](https://metacpan.org/pod/Sereal), make sure to instantiate the [Sereal encoder](https://metacpan.org/pod/Sereal%3A%3AEncoder) with the `freeze_callbacks` option set to true, otherwise, `Sereal` will not use the `FREEZE...

See ["FREEZE/THAW CALLBACK MECHANISM" in Sereal::Encoder](https://metacpan.org/pod/Sereal%3A%3AEncoder#FREEZE-THAW-CALLBACK-MECHANISM) for more information.

For [CBOR](https://metacpan.org/pod/CBOR%3A%3AXS), it is recommended to use the option `allow_sharing` to enable the reuse of references, such as:

    my $cbor = CBOR::XS->new->allow_sharing;

Also, if you use the option `allow_tags` with [JSON](https://metacpan.org/pod/JSON), then all of those modules will work too, since this option enables support for the `FREEZE` and `THAW` methods.

# AUTHOR

Jacques Deguest <`jack@deguest.jp`>

# SEE ALSO

[Locale::Unicode](https://metacpan.org/pod/Locale%3A%3AUnicode), [Locale::Unicode::Data](https://metacpan.org/pod/Locale%3A%3AUnicode%3A%3AData), [DateTime::Format::Unicode](https://metacpan.org/pod/DateTime%3A%3AFormat%3A%3AUnicode)

[DateTime::Locale](https://metacpan.org/pod/DateTime%3A%3ALocale)

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



( run in 0.932 second using v1.01-cache-2.11-cpan-39bf76dae61 )