The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Locale::Object::Language - language information objects

DESCRIPTION

Locale::Object::Language allows you to create objects containing information about languages such as their ISO codes, the countries they're used in and so on.

SYNOPSIS

    use Locale::Object::Language;

    my $eng = Locale::Object::Language->new( code_alpha3 => 'eng' );

    my $name        = $eng->name;
    my $code_alpha2 = $eng->code_alpha2;
    my $code_alpha3 = $eng->code_alpha3;
    
    my @countries = $eng->countries;

    my $gb  = Locale::Object::Country->new(  code_alpha2 => 'gb'  );

    print $eng->official($gb); 

METHODS

new()

    my $eng = Locale::Object::Language->new( code_alpha3 => 'eng' );

The new method creates an object. It takes a single-item hash as an argument - valid options to pass are ISO 3166 values - 'code_alpha2', 'code_alpha3' and 'name'.

The objects created are singletons; if you try and create a currency object when one matching your specification already exists, new() will return the original one.

name(), code_alpha2(), code_alpha3()

    my $name = $country->name;
    

These methods retrieve the values of the attributes in the object whose name they share.

countries()

    my @countries = $eng->countries;

Returns an array (in array context, otherwise a reference) of Locale::Object::Country objects with their ISO 3166 alpha2 codes as keys for all countries using this currency in array context, or a reference in scalar context. The objects have their own attribute methods, so you can do things like this for example:

    foreach my $place (@countries)
    {
      print $place->name, "\n";
    }
    

Which will list you all the countries that use in that currency. See the documentation for Locale::Object::Country for a listing of country attributes. Note that you can chain methods as well.

    foreach my $place (@countries)
    {
      print $place->continent->name, "\n";
    }

official()

    my $gb = Locale::Object::Country->new(  code_alpha2 => 'gb'  );

    print $eng->official($gb);  # prints 'true'

Give this method a Locale::Object::Country object, and it will return a 'true' or 'false' value for whether the country the object represents has the language represented by your Locale::Object::Language object as an official language. See Locale::Object::Database for a note about languages in the database.

OBSOLETE LANGUAGE CODES

ISO 639 is not immune from change, and there are three codes that changed in 1995: Hebrew (he, was iw), Indonesian (id, was in) and Yiddish (yi, formerly ji). Because the database maintains a one-to-one mapping, the old codes aren't included; if you need to support them for some reason (apparently Java versions previous to 1.4 use 'iw', for example), you'll have to alias them yourself. Thanks to Robin Szemeti (RSZEMETI) for bringing this to my attention.

KNOWN BUGS

The database of language information is not perfect by a long stretch. In particular, numerous comparatively obscure secondary or regional languages that don't have ISO codes, such as in several African countries and India, are missing. (See note in Locale::Object::Database about data sources.) Please send any corrections to the author.

AUTHOR

Originally by Earle Martin

COPYRIGHT AND LICENSE

Originally by Earle Martin. To the extent possible under law, the author has dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.